12

I'm running 3 nodes with the following command:

geth --verbosity 4 --autodag --nat any --genesis /opt/blockchain/genesis.json \
     --datadir /opt/blockchain/data --networkid 4828 --port 30303 --rpc \
     --rpcaddr 10.48.247.25 --rpcport 8545 --rpcapi db,eth,net,web3,admin \
     --rpccorsdomain '*' --fast --mine --ipcdisable

The genesis.json file is the same for every node (I've checksumed them to be sure).

What happens is the nodes can't find each other alone, I have to manually connect them throw admin.addPeer.

To test it, I've created a interval loop in the console to print admin.peers every 1 sec.:

var interval = setInterval(function(){console.log(admin.peers)}, 1000);

If if connect node 1 to node 2 (1--2), they keep connecting to and disconnecting from each other. But node 3 is not able to connect to any of them.

Why is this happening?

Henrique Barcelos
  • 2,481
  • 4
  • 20
  • 38

1 Answers1

8

Each of the geth instances will need to discover at least one other instance with a connection to the rest of your private network.

You could nominate one (or more) of your geth instances as a bootnode that all the other instances first connect to in order to find other peers in your private network. To specify the bootnode that the non-bootnode instances should connect to initially, use the following command line parameter (from https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network#connecting-to-the-network) :

geth --bootnodes "enode://pubkey1@ip1:port1 [enode://pubkey2@ip2:port2 [enode://pubkey3@ip3:port3]]"

You could alternatively nominate one (or more) of the nodes as a static node that other peers will always connect to (from https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network#static-nodes) by adding the file /static-nodes.json for each geth instance with the following content:

[
  "enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0@33.4.2.1:30303",
  "enode://pubkey@ip:port"
]

Remember to remove the comma ',' if you only have one geth instance in your static-nodes.json file (Can anyone help guide on running two geth clients on the same box and same network?).

BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193
  • 1
    So basically there is no way of just connecting a node to a network and it starts to ping other nodes automatically in order to obtain the history? – Henrique Barcelos Apr 07 '16 at 12:52
  • 1
    Unlike UDP where you can broadcast a ping (and does not work over the Internet), the TCP protocol requires some starting addresses and ports. There are a few ip:ports hardcoded in the source code that all Ethereum nodes check with in the live network - the bootnodes. – BokkyPooBah Apr 07 '16 at 12:56