Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

port

json-rpc

rsk

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.

like image 940
serlokiyo Avatar asked Feb 22 '21 08:02

serlokiyo


1 Answers

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.

like image 109
bguiz Avatar answered Nov 14 '22 00:11

bguiz