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?

1 Answer 1

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?).

2
  • 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? Apr 7, 2016 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. Apr 7, 2016 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.