Search code examples
dockerwebsocketsubstratepolkadotpolkadot-js

Polkadot websocket API doesn't listen for new blocks


Im using the polkadot.js api, running from a shell, and expecting to get multiple "Chain is at block #12345" messages. But i only get 1 of these messages and I do not know why.

I'm running a Polkadot node using the following docker command:

docker run -it -p 30333:30333 -p 9944:9944 -p 80:9933 -v /mnt/polkadot:/polkadot/.local/share parity/polkadot:latest --rpc-external --rpc-cors=all --chain westend --ws-external

and am following the examples in the polkadot.js api documentation

If i stop the docker container and then restart it i get 1 more message, so i know the connection is still open. it seems like the node isnt emitting the messages.

If I query wss://rpc.polkadot.io instead of my node (on port 9944) I get the expected behaviour.

Can anyone suggest a solution or steps to investigate?


Solution

  • The problem seems to be due to the node syncing with the network.

    The node finished syncing the Westend network an hour ago and the API is now working as expected.