Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Received invalid host specified when connecting on RPC #124

Closed
cdesch opened this issue Apr 8, 2021 · 9 comments
Closed

Received invalid host specified when connecting on RPC #124

cdesch opened this issue Apr 8, 2021 · 9 comments

Comments

@cdesch
Copy link

cdesch commented Apr 8, 2021

I got the error: Error: Invalid JSON RPC response: "invalid host specified\n" when trying to connect to the 8545 through a traefik IngressRoute.

I tried adding:

            --rpccorsdomain=\"*\" --rpcvhosts=\"*\" --ws --wsorigins=\"*\" --wsaddr 0.0.0.0 \

to the deployment.yaml but did not work

@cdesch
Copy link
Author

cdesch commented Apr 8, 2021

More info:

Using:

quorum 2.6.0 

and

traefik.containo.us/v1alpha1 
kind: IngressRoute

I see in this commit of geth ethereum/go-ethereum@beabf95 that they are moving from using the params like rpccorsdomain to http.corsdomain, although I can see that in v2.6.0 in PR#960 that only geth 1.9.7 is currently supported.

How should k8s be configured?

@bmcd
Copy link
Contributor

bmcd commented Apr 9, 2021

It seems like that's usually related to not having the rpcvhosts value, like you thought originally. Are you sure that the geth start command was updated successfully and ran with the new flags you added?

Also, how are you connecting to the RPC endpoint?

@cdesch
Copy link
Author

cdesch commented Apr 9, 2021

thanks @bmcd

I'm 90% sure that the flags were applied as I did a kubectl delete and redeploy with kubectl apply after making the changes to the flags in the deployment.yaml. Maybe the args are being overwritten somewhere? Is there any way to check in the geth node, in the pod, if the flags have been applied? I know you can usually attach directly to geth nodes from inside the host (like this) but I'm not sure if that is the same in quorum.

@cdesch
Copy link
Author

cdesch commented Apr 12, 2021

@bmcd How is this supposed to be put in?

this is what I have:

           --permissioned \
           --nodiscover \
           --nat=none \
           --verbosity 9 \
           --networkid $NETWORK_ID \
           --unlock 0 \
           --emitcheckpoints \
           --rpc \
           --rpcaddr 0.0.0.0 \
           --rpcport 8545 \
           --rpcapi $RPC_APIS \
           --wsapi $RPC_APIS \
           --wsport 8546 \
           --port 30303 \
           --rpccorsdomain \"*\" \
           --rpcvhosts \"*\" \

@cdesch
Copy link
Author

cdesch commented Apr 12, 2021

@bmcd Adding vhosts and corsdomain crashes the containers every time and results in a k8s crashloop for the quorum container. How are these params formatted and where do they go in the deployment?

Here is the config:

- name: quorum
        image: quorumengineering/quorum:2.6.0
        readinessProbe:
          exec:
            command:
              - ls
              - $(QHOME)/dd/geth.ipc
          initialDelaySeconds: 20
          periodSeconds: 3
        command: [ "sh" ]
        # TODO: have to generate sed files
        #       PERM_NODE_JSON=$(echo $PERM_NODE_TMPL | sed \"s/%QUORUM-NODE01_SERVICE_HOST%/$QUORUM_NODE01_SERVICE_HOST/g\" | sed \"s/%QUORUM-NODE02_SERVICE_HOST%/$QUORUM_NODE02_SERVICE_HOST/g\");
        # sleep to give constellation some time to start up and discover the other nodes.
        #  --maxpeers 4
        args:
        - "-cx"
        - "
          export HTTP_PROXY=http://my.com:8000;
          export HTTPS_PROXY=http://my.com:8000;
          export NO_PROXY=localhost,127.0.0.1,*.my.com;

           apk add curl;
           apk add jq;

           sh $QHOME/permission-nodes/permissioned-update.sh;
           rm -r /etc/quorum/qdata/contracts-tmp;
           echo what in this dir;
           ls  $QUORUM_DATA_DIR;
           cat /etc/quorum/genesis/genesis-geth.json;

           chmod 644 $QUORUM_DATA_DIR/keystore/key;
  
           until $(curl --output /dev/null --silent --head --fail http://127.0.0.1:9001/upcheck); do echo 'waiting for transaction manager to start...'; sleep 5; done;
           echo transaction manager is up;


           touch $QUORUM_DATA_DIR/password.txt;
           NETWORK_ID=1101
           RPC_APIS=admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum
           args=\" --gcmode archive --istanbul.blockperiod 3 --syncmode full --mine --minerthreads 1 \";
           RPC_APIS=\"$RPC_APIS,istanbul\";
           args=\"$args --allow-insecure-unlock \";
           /usr/local/bin/geth \
           --datadir $QUORUM_DATA_DIR \
           $args \
           --permissioned \
           --nodiscover \
           --nat=none \
           --verbosity 9 \
           --networkid $NETWORK_ID \
           --unlock 0 \
           --emitcheckpoints \
           --rpc \
           --rpcaddr 0.0.0.0 \
           --rpcport 8545 \
           --rpcapi $RPC_APIS \
           --wsapi $RPC_APIS \
           --wsport 8546 \
           --port 30303 \
            \
           --password $QUORUM_DATA_DIR/password.txt 2>&1 | tee -a /etc/quorum/qdata/logs/quorum.log;"
        ports:
          - containerPort: 50401
          - containerPort: 8545
          - containerPort: 8546
          - containerPort: 30303

I've tried variations below and more and have not had any success:

       --rpccorsdomain='*' \
       --rpcvhosts='*' \

      --rpccorsdomain \"*\" \
      --rpcvhosts \"*\" \

      --rpccorsdomain=\"*\" \
      --rpcvhosts=\"*\" \

      --rpccorsdomain * \
      --rpcvhosts * \

      --rpccorsdomain=* \
      --rpcvhosts=* \

      --rpccorsdomain='*' \
      --rpcvhosts='*' \

@bmcd
Copy link
Contributor

bmcd commented Apr 12, 2021

Hmm, not sure. When I use wizard to generate a qubernetes project it looks like:

           /usr/local/bin/geth \
           --datadir $QUORUM_DATA_DIR \
           $args \
           --permissioned \
           --nodiscover \
           --nat=none \
           --verbosity 9 \
           --networkid $NETWORK_ID \
           --unlock 0 \
           --emitcheckpoints \
           --rpc \
           --rpcaddr 0.0.0.0 \
           --rpcport 8545 \
           --rpcapi $RPC_APIS \
           --wsapi $RPC_APIS \
           --wsport 8546 \
           --port 30303 \
           --rpccorsdomain=\"*\" --rpcvhosts=\"*\" --wsorigins=\"*\" \
           --password $QUORUM_DATA_DIR/password.txt 2>&1 | tee -a /etc/quorum/qdata/logs/quorum.log;"

There are no errors in the logs from when it crashes?

@cdesch
Copy link
Author

cdesch commented Apr 12, 2021

hmm... The order seems to matter. This works:

           $args \
           --permissioned \
           --nodiscover \
           --nat=none \
           --verbosity 9 \
           --networkid $NETWORK_ID \
           --unlock 0 \
           --emitcheckpoints \
           --rpc \
           --rpcaddr 0.0.0.0 \
           --rpcport 8545 \
           --rpcapi $RPC_APIS \
           --rpccorsdomain=\"*\" \
           --rpcvhosts=\"*\" \
           --wsapi $RPC_APIS \
           --wsport 8546 \
           --port 30303 \
            \
           --password $QUORUM_DATA_DIR/password.txt 2>&1 | tee -a /etc/quorum/qdata/logs/quorum.log;"

our config also has that trailing \ before the --password... I wonder if that was messing it up.

I take it websockets are the same?

@bmcd
Copy link
Contributor

bmcd commented Apr 12, 2021

it looks like that line is where qubernetes puts the Geth_Startup_Params value from the qubernetes.yaml file. So since it's empty in your config it just puts the \. You can delete that line.

When you say it works, you mean it doesn't crash anymore? Or the rpc endpoint also no longer shows the invalid host error?

websockets use the --wsorigins="*" flag instead of corsdomain and vhosts.

@cdesch
Copy link
Author

cdesch commented Apr 12, 2021

Thanks! Nice to have it working a little. I'll close the issue.

@cdesch cdesch closed this as completed Apr 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants