Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to add ethereum peer. Peer list is empty

Tags:

ethereum

I am trying to setup a private ethereum network. I started two nodes in the same machine (Windows 7) in two different ports.

I am unable to add one node as the peer of the other node. What I have done so far is this.

Start two nodes with same network id, different data dirs, and different ports.

Find the node address of one node.

> admin.nodeInfo.enode
"enode://5d272e8bee6d29dfff6313999a4a2c3d8109ae6f3eb103480f4536c0542549b9fa12a8d8ae5ebee9c4db55cab553693b04eedbc9b29f35bbc0af1956231b42b4@0.0.0.0:30303"

Add the node to the other peer.

> admin.addPeer("enode://5d272e8bee6d29dfff6313999a4a2c3d8109ae6f3eb103480f4536c0542549b9fa12a8d8ae5ebee9c4db55cab553693b04eedbc9b29f35bbc0af1956231b42b4@192.168.1.5:30303")

true

But, if I check peer information of the second peer, it shows that it doesn't have any peers.

> admin.peers

[]

Also, I tried to add the first peer as a static peer for the second node by adding node address to data/static-nodes.json, but still admin.peers returns an empty list.

Does anyone know how to fix this?

like image 287
Lahiru Chandima Avatar asked Oct 30 '16 12:10

Lahiru Chandima


1 Answers

There are many reasons which could prevent the nodes to get sync-ed.

System Clocks not Sync

One of the most common but difficult-to-find reasons is that the system clocks of the devices do not sync. The nodes do not sync even if the clocks are differ by just 12 seconds.

From https://github.com/ethereum/wiki/wiki/Mining :

The difficulty dynamically adjusts so that on average one block is produced by the entire network every 12 seconds (ie., 12 s block time). This heartbeat basically punctuates the synchronisation of system state and guarantees that maintaining a fork (to allow double spend) or rewriting history is impossible unless the attacker possesses more than half of the network mining power (so called 51% attack).

The problem could be solved by using the same NTP server (preferably geographically close to the network) on all devices.

Network IDs not Matched

By using the --networkid 12345 option on the command line, the network ID of the network is set to 12345. Please make sure that the settings are the same among all nodes, and that the value is a random positive unsigned 32-bit number (ie. 1 ~ 2147483647). Do not use 12345, since there may be too many people using it.

Firewall not Properly Configured

Ethereum uses TCP and UDP ports 30303 by default to communicate with each other. Please make sure that both 30303/TCP and 30303/UDP are not blocked by the firewall on the device.

like image 191
Siu Ching Pong -Asuka Kenji- Avatar answered Nov 12 '22 03:11

Siu Ching Pong -Asuka Kenji-