- Geth version: v1.6.0-unstable-1018bf6a/linux/go1.7.3
- OS & Version: Linux/Ubuntu 16.04.1 LTS (x86_64)
I want to set up a private distributed blockchain network. I am failing to make nodes (running on different machines) recognize each other.
Both nodes have the same genesis file and are connected to the same networkId.
INFO Successfully wrote genesis state hash=X (hash equal on both nodes)
The UDP Port 30301 of the bootnode is open
> netcat -u -z -v <PUB-IP> 30301
Connection to <PUB-IP> 30301 port [udp/*] succeeded!
When I start the bootnote I pass the following arguments:
--nodekey <FILE> —addr :30301 --nat extip:<PUB-IP> --verbosity 9
The logs confirm that it is successfully created and listening:
INFO Mapped network port proto=udp extport=30301 intport=30301 interface=ExtIP(<PUB-IP>)
DEBUG UDP listener up self=enode://<PUB-ID>@<PUB-IP>:30301
When I start the node I pass the following arguments:
--cache=512 --verbosity=6 --datadir <DIR> --nat extip:<PUB-IP> --networkid=<VAL*> --rpc --rpcaddr=0.0.0.0 --rpcapi=eth,net,web3,personal,db --rpccorsdomain '*' --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --bootnodes enode://<PUB-ID>@<PUB-IP>:30301 --identity node1
*(I am using a big networkId but it is inside the BigInteger range)
The logs on the node confirm that the bootnode is well identified
INFO Starting P2P networking
# >> Info about the current node:
DEBUG UDP listener up self=enode://<PUB-ID>@<PUB-IP>:30303
INFO Mapped network port proto=udp extport=30303 intport=30303 interface=ExtIP(<PUB-IP>)
# >> Info about the bootnode:
TRACE Starting bonding ping/pong id=<PUB-ID-SHORT> known=false failcount=0 age=XmXs
But connection fails and admin.peers
shows no peers
TRACE >> PING/v4 addr=<PUB-IP>:30301 err=nil
TRACE Starting bonding ping/pong id=<PUB-ID-SHORT> known=false failcount=0 age=XmXs
TRACE >> PING/v4 addr=<PUB-IP>:30301 err=nil
When I try adding the bootnode manually, admin.addPeer("enode://..")
returns true but the logs show:
DEBUG Adding static node node=enode://<PUB-ID>@<PUB-IP>:30301
TRACE New dial task task="staticdial <PUB-ID-SHORT> <PUB-IP>:30301"
TRACE Dial error task="staticdial <PUB-ID-SHORT> <PUB-IP>:30301" err="dial tcp <PUB-IP>:30301: getsockopt: connection refused"
DEBUG Resolving node failed id=<PUB-ID-SHORT> newdelay=2m0s
TRACE Dial task done task="staticdial <PUB-ID-SHORT> <PUB-IP>:30301"
TRACE New dial task task="staticdial <PUB-ID-SHORT> <PUB-IP>:30301"
TRACE Dial error task="staticdial <PUB-ID-SHORT> <PUB-IP>:30301" err="dial tcp <PUB-IP>:30301: getsockopt: connection refused"
TRACE Dial task done task="staticdial <PUB-ID-SHORT> <PUB-IP>:30301"
I have tried as well to connect via static-nodes.json
, where I indicate the bootnode's address in all nodes; and also without the --bootnodes
flag, where somehow my nodes are not being recognized either, yet there are some random external nodes that are displayed as peers sporadically. I have tried specifying --maxpeers
(following BokkyPooBah's advice) as well and seems to make no difference.
Please, help me.
Best Answer
Finally it worked. I still don't really know what did it but I will list here some of the changes that got it to work. When I figure out what exactly did it I will update my answer.
--v5disc
flag for node discovery.--v5
flag so instead of using a bootnode I chose a random node as bootnode. I started my node with the--bootnodes
referring to this regular node but didn't seem to work until I manually added it. Probably usingstatic-nodes.json
would have worked as well.Protocol eth/63 failed id=X conn=inbound err="NetworkId mismatch - 3853220132 (!= 1245324517197969700)"
. I am now using a 10-digit networkId and this is what seems to have done the trick.personal.newAccount("pw")
,miner.setEtherbase(eth.accounts[0])
&miner.start()
)I am more inclined to think it was the networkId that was causing some sort of problem. At least switching to
v5
made it more easy to detect.