How to avoid "PeerDiscoveryException" when running RSK node on Windows?
Asked Answered
I

1

7

I started running RSK node on Windows and when I tried:

curl -X POST -H "Content-Type:application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:4444

I always get:

{"jsonrpc":"2.0","id":1,"result":"0x0"}

This obviously means that my node is not syncing, so I checked the logs and found Address already in use:

 Exception in thread "UDPServer" co.rsk.net.discovery.
 PeerDiscoveryException: Discovery can't be started.
 At co.rsk.net.discovery.UDPServer$1.run(UDPServer.java:65) - caused by: java.net.BindException: Address already in use...

I do not have any other RSK instance running, so I'm not sure why I'm getting this error.

Issie answered 22/2, 2021 at 8:51 Comment(0)
I
6

You need to change your peer discovery port (peer.port) to use a different one. This is because RSK Mainnet uses 5050 as default peer discovery port and Windows usually has smaller port numbers already assigned for other uses.

For example, to start RSKj with a peer discovery port of 50506, use the following command:

java \
  -D peer.port=50506 \
  -cp <PATH-TO-THE-RSKJ-JAR> \
  co.rsk.Start \
  --regtest

You may also choose to set peer.port=50506 in the relevant config file.

NOTE: This issue does not usually occur on RSK Testnet because its default peer discovery port is 50505, a much larger port number. This issue usually does not occur on other operating systems because that RSK Mainnet port number is typically unused.

Inhalator answered 22/2, 2021 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.