I'm trying to connect to my RSK node via a websocket:
wscat -c ws://localhost:4445/websocket
However, I get this result: Error: connect ECONNREFUSED 127.0.0.1:4445
.
The docs say that websocket listens to port 4445
by default.
How do I connect correctly?
Websockets are disabled by default. See RSKj configuration reference
To enable websockets on RSKj:
(1)
Add -Drpc.providers.web.ws.enabled=true
to your java
command when starting RSKj.
(2)
Update the configuration file.
The file is named mainnet.conf
for RSK Mainnet.
Your config file should look like this:
rpc {
providers : {
web: {
cors: "*",
http: {
enabled: true,
bind_address = "0.0.0.0",
hosts = ["localhost", "127.0.0.1"],
port: 4444,
}
ws: {
enabled: true,
bind_address: "127.0.0.1",
hosts = ["localhost", "127.0.0.1"],
port: 4445,
}
}
}
...
}
After this, restart your RSKj for the config to take effect. Now if you repeat the same command from your question:
wscat -c ws://localhost:4445/websocket
You should be able to establish a connection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With