go-ethereum – How to Run Two Geth Clients on the Same Box and Network

datadirgo-ethereumsynchronization

I am working on Mac OSX. I have the CL tools installed and I can start one geth client on a private network. Mining works. Wallet features work. I am able to successfully mine eth and deposit it into the primary/default account of Geth1.

Then I run another instance of geth. Same network id, same genesis JSON, different data directory. I removed the runtime rpc flags. I am unable to get the Geth2 client to connect and mine on the same network.

NodeInfo on Geth1 and Geth2 shows the IP address as null. I'm not sure where that is supposed to be populated or if it is the culprit.

Can anyone provide a pointer what I might look at next to make the second client connect to the network started by the first?

Here is the command line for each:

Starting console:

geth --genesis /Users/myuser/ethereum/TestNetOne/TestNetOne-Genesis.json --nodiscover --maxpeers 3 --datadir "/Users/myuser/ethereum/TestNetOne" --identity "TestNetOne" --networkid 21863 --rpc --rpcport "8080" --rpccorsdomain "" --port "30304" --rpcapi "db,eth,net,web3" console

Second console:

geth --genesis /Users/myuser/ethereum/TestNetOne/TestNetOne-Genesis.json --nodiscover --maxpeers 3 --datadir "/Users/myuser/ethereum/TestNetOne/data_dir1" --identity "TestNetOne" --networkid 21863 console

The second console also has a static-nodes.json in its data_dir with the following:

[
"enode://482238402e50522795112b309891111ce933d20ebebee712c687a3ea3479f8b441532019bd99a6451549fa82e4134215664eb550323043040242e67c15684c63@127.0.0.1:30304",
]

That enode is the enode Id of the first geth process.

Thanks in advance!

Best Answer

Your static-nodes.json file has an invalid ',' character near the end of the string. This is copied from your original post:

[
"enode://482238402e50522795112b309891111ce933d20ebebee712c687a3ea3479f8b441532019bd99a6451549fa82e4134215664eb550323043040242e67c15684c63@127.0.0.1:30304",
]

When I set up my equivalent static-nodes.json file with the ',' character, I get the following message on the console of my second geth instance:

I0401 08:46:07.165779   29936 backend.go:186] Failed to load nodes: invalid character ']' looking for beginning of value

After removing the ',' character from my second geth instance static-nodes.json, the instance successfully connects to the first geth instance.

If the ',' above is not the problem, does the following command in geth successfully connect to your first geth node instance?

admin.addPeer("enode://482238402e50522795112b309891111ce933d20ebebee712c687a3ea3479f8b441532019bd99a6451549fa82e4134215664eb550323043040242e67c15684c63@127.0.0.1:30304")
Related Topic