2

I'm running 3 validator nodes on different vm instances on gcp but I'm not able to connect these node with the polkadot UI.

Here are the commands which I'm using to run the nodes:

./target/release/node-template --base-path /tmp/bob --chain local --bob --port 30335 --rpc-port 9944 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator -lruntime=debug --rpc-methods Unsafe   --name bob   --bootnodes /ip4/external-ip/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
./target/release/node-template --base-path /tmp/alice --chain local --alice --port 30333 --rpc-port 9945 --node-key 0000000000000000000000000000000000000000000000000000000000000001 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator -lruntime=debug
./target/release/node-template --base-path /tmp/charlie --chain local --charlie --port 30334 --rpc-port 9945 --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" --validator -lruntime=debug --bootnodes /ip4/external-ip/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp

I tried to run this command on instances to get port info:

deepak$ netstat -tuln | grep 9944
tcp        0      0 127.0.0.1:9944          0.0.0.0:*               LISTEN

On polkadot UI, I'm putting this as a endpoint: wss://external-ip:9945

After adding --unsafe-rpc-external

I'm not still facing the same issue on polkadot UI. Here are logs which happens when UI tries to connect:

2024-02-23 07:07:46.958  INFO tokio-runtime-worker jsonrpsee_server::server: Accepting new connection 1/100
2024-02-23 07:07:46.958  WARN tokio-runtime-worker jsonrpsee_server::server: HTTP serve connection failed hyper::Error(Parse(Method))
2024-02-23 07:07:47.514  INFO tokio-runtime-worker jsonrpsee_server::server: Accepting new connection 1/100
2024-02-23 07:07:47.514  WARN tokio-runtime-worker jsonrpsee_server::server: HTTP serve connection failed hyper::Error(Parse(Method))
2024-02-23 07:07:48.538  INFO tokio-runtime-worker substrate: 💤 Idle (2 peers), best: #675 (0x2144…a767), finalized #673 (0x6018…0a29), ⬇ 2.1kiB/s ⬆ 1.8kiB/s  

How can i solve this issue?

Just FYI: websocket is not secured

1 Answer 1

1

you need to pass the flag --unsafe-rpc-external to listen in all interfaces, since currently the rpc is only listening on localhost so can't be connected from outside (or you need a proxy in front to listen connections and route to the node/s).

      --unsafe-rpc-external
          Listen to all RPC interfaces.

Update: With this the instance is ready to accepting connection over the extenal-ip but using polkadotjs apps will not works since the browser restrictions of open a ws connection from a secure sire (https). To workaround this you can create a reverse tunnel with ssh and use localhost to connect to your instance. The tunnel can be created with this command

ssh -g -L 9945:localhost: 9945 -f -N user@gcp-intance

And then you can use ws://localhost:9945

Thx!

8
  • Yeah, Now I'm able to see this: '$ netstat -tuln | grep 9944 tcp 0 0 0.0.0.0:9944 0.0.0.0:* LISTEN ' But on polkadot UI connection is not successful, getting this - Waiting to establish a connection with the remote endpoint. Feb 22 at 8:10
  • You may need to allow ingress traffic to those ports in GCP, since ingress could be disable by default.
    – pepoviola
    Feb 22 at 10:31
  • Checked! all the ports are open.still facing the same issue. Updated the question with logs which get generated when UI tries to connect. Feb 23 at 7:12
  • 1
    By UI you mean https://polkadot.js.org? Also, the ws connection should be something like ws://external-ip:9945. You can also trying adding the flag --rpc-cors all to allow all origins
    – pepoviola
    Feb 23 at 10:05
  • 1
    That because the browser have a security restriction, there are a few ways to resolve this like create a tunnel that allow to use localhost to initialize the ws connection. For example with ssh -g -L 9945:localhost: 9945 -f -N user@gcp-intance and then you can just use ws://localhost:9945 to connect.
    – pepoviola
    Feb 23 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.