6

OBJECTION to duplicate problem: The supposed duplicate answer DOES NOT work. The problem wording is similar but the problem itself requires a different solution.

I created a local private chain like below

geth --genesis ...CustomGenesis.json --verbosity 6 --datadir ...customchain1\chain --identity SomeChain --blockchainversion 12 --networkid 123 --rpcport 8101 --maxpeers 15 console 

Launching the wallet, I have to skip peer search because it never finishes. After opening I can see I'm in PRIVATE-NET but with 0 peers.

I noticed I needed 12 peers for validation of contracts so I tried creating 1-2 nodes to see if this would work. I used below tutorial and some others I forgot.

https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network

Initially, I created another folder with geth.exe in it. then used the below command on a seperate console while the main geth.exe was already running.

geth --datadir="...\customchain1\node1\chain" --verbosity 6 --networkid 123 --ipcdisable --port 30302 --rpcport 8102 console

I used admin.nodeInfo.enode on the node geth console to get enode value. Then used below command on the primary geth console to add as peer.

admin.addPeer("enode://7a68ad5995ed4fa02a20f582e0c41bd6afad609102edda3fe3b443b618e56b11282d78cbeddfd2b8fb846a36ed6230d446fb41dc5fd77ff97bf20502e7ce0568@[::]:30302")

EDIT Adding " before and after enode returns true but admin.peers returns nothing still.

This returns (anonymous): Line 1:20 Unexpected token :

I then copied the genesis file I used to create the blockchain, deleted everything else and ran the exact same command within the node folder. I retrieved the enode line and tried again. The error was the same.

Am I misunderstanding how this should work or is there something else I'm missing?

Thank you.

EDIT Almost There Some logs I captured. Seems that they do almost connect then drop due to mismatched networkID but where the hell does it get that number from? I have nothing with networkID 1602902873 and I explicitly state the networkID differently in all commands.

10:42:11.869273 p2p/server.go:428] new task: static dial 07837c0f7f31ad77 127.0.0.1:30301
10:42:11.869273 p2p/server.go:428] new task: static dial b708f0574d3b88af 127.0.0.1:30302
10:42:11.869273 p2p/server.go:428] new task: static dial 38754ca3bd38f3b7 127.0.0.1:30303
10:42:11.869273 p2p/server.go:428] new task: discovery lookup
10:42:11.869273 p2p/dial.go:263] dial tcp 127.0.0.1:30301 (07837c0f7f31)
10:42:11.870275 p2p/dial.go:263] dial tcp 127.0.0.1:30302 (b708f0574d3b)
10:42:11.870275 p2p/dial.go:263] dial tcp 127.0.0.1:30303 (38754ca3bd38) 
10:42:11.876277 p2p/server.go:477] <-posthandshake: static dial conn 07837c0f7f31ad77 127.0.0.1:30301 
10:42:11.877278 p2p/server.go:477] <-posthandshake: static dial conn b708f0574d3b88af 127.0.0.1:30302
10:42:11.878279 p2p/server.go:483] <-addpeer: static dial conn 07837c0f7f31ad77 127.0.0.1:30301
10:42:11.878279 p2p/server.go:672] Added Peer 07837c0f7f31ad77 127.0.0.1:30301
10:42:11.878279 p2p/server.go:467] <-taskdone: static dial 07837c0f7f31ad77 127.0.0.1:30301
10:42:11.878279 p2p/peer.go:301] Peer 07837c0f7f31ad77 127.0.0.1:30301: Starting protocol eth/63
10:42:11.879280 eth/handler.go:231] Peer 07837c0f7f31ad77 [eth/63]: peer connected [Geth/v1.4.4-stable/windows/go1.5.1/CustomChainPOCNode2]
10:42:11.879280 p2p/server.go:483] <-addpeer: static dial conn b708f0574d3b88af 127.0.0.1:30302
10:42:11.879280 p2p/server.go:672] Added Peer b708f0574d3b88af 127.0.0.1:30302
10:42:11.879280 eth/handler.go:236] Peer 07837c0f7f31ad77 [eth/63]: handshake failed: NetworkId mismatch - 1602902873 (!= 123)
10:42:11.879280 p2p/peer.go:308] Peer 07837c0f7f31ad77 127.0.0.1:30301: Protocol eth/63 error: NetworkId mismatch - 1602902873 (!= 123)
10:42:11.879280 p2p/peer.go:177] Peer 07837c0f7f31ad77 127.0.0.1:30301: protocol error: NetworkId mismatch - 1602902873 (!= 123) (Subprotocol error)
10:42:11.879280 p2p/server.go:477] <-posthandshake: static dial conn 38754ca3bd38f3b7 127.0.0.1:30303
10:42:11.880280 p2p/server.go:467] <-taskdone: static dial b708f0574d3b88af 127.0.0.1:30302
10:42:11.882281 p2p/peer.go:301] Peer b708f0574d3b88af 127.0.0.1:30302: Starting protocol eth/63
10:42:11.882281 eth/handler.go:231] Peer b708f0574d3b88af [eth/63]: peer connected [Geth/v1.4.4-stable/windows/go1.5.1/CustomChainPOCNode1]
10:42:11.882281 eth/handler.go:236] Peer b708f0574d3b88af [eth/63]: handshake failed: NetworkId mismatch - 1602902873 (!= 123)
10:42:11.884283 p2p/peer.go:308] Peer b708f0574d3b88af 127.0.0.1:30302: Protocol eth/63 error: NetworkId mismatch - 1602902873 (!= 123)
10:42:11.884283 p2p/peer.go:177] Peer b708f0574d3b88af 127.0.0.1:30302: protocol error: NetworkId mismatch - 1602902873 (!= 123) (Subprotocol error)
10:42:11.881281 p2p/server.go:626] static dial conn 38754ca3bd38f3b7 127.0.0.1:30303 failed checkpoint posthandshake: Connected to self
10:42:11.882281 p2p/server.go:499] <-delpeer: Peer 07837c0f7f31ad77 127.0.0.1:30301
10:42:11.888287 p2p/server.go:467] <-taskdone: static dial 38754ca3bd38f3b7 127.0.0.1:30303
10:42:11.888287 p2p/server.go:499] <-delpeer: Peer b708f0574d3b88af 127.0.0.1:30302
10:42:11.882281 p2p/server.go:688] Removed Peer 07837c0f7f31ad77 127.0.0.1:30301 (Subprotocol error)
10:42:11.890288 p2p/server.go:688] Removed Peer b708f0574d3b88af 127.0.0.1:30302 (Subprotocol error)

SHAME...SHAME...SHAME...bell rings So while trying to understand how a random magical networkID appears instead of the one I gave. I noticed it was an Integer if written without quotes. I had a number beyond the max int value. When I fixed it to something acceptable it worked immediately.

7

In the admin.addPeer() function, you'll have to mention the IP address in the place of [::]. It looks like you're working on the same workstation. In this case, mention the localhost address while adding a peer. Your command should be:

admin.addPeer("enode://7a68ad5995ed4fa02a20f582e0c41bd6afad609102edda3fe3b443b618e56b11282d78cbeddfd2b8fb846a36ed6230d446fb41dc5fd77ff97bf20502e7ce0568@127.0.0.1:30302")

Similarly, if you're working on a different workstation in the local network, you need to use the private IP address.

You need to use the same genesis file and network ID for all the nodes. Every node should have a different port #, different rpc port #, and a different data directory(if working on the same system).

Check this page for more info.

  • 2
    I cleared node chain files, then recreated using the same genesis as geth --genesis ...\customchain1\node1\CustomGenesis.json --datadir ...\customchain1\node1\chain --networkid 123 --ipcpath ~/Library/Ethereum/node1/geth.ipc --port 30302 --rpcport 8102 --maxpeers 15 console Different ports and ipcpath for node2. Then got the enodes and used addPeer with IP. I tried from primary node and new nodes. All returned true but admin.peers is empty in all nodes :( – mechanicum Jun 17 '16 at 13:28
  • 1
    Check whether net.listening returns true before adding the peers. Check with net.peerCount if you actually have the peers connected. Please check this link and let me know if you still have problems. – galahad Jun 17 '16 at 14:09
  • 1
    its true. peerCount is 0 always. I did the exact same geth commands in the link. Updating the question text. – mechanicum Jun 17 '16 at 14:27
  • 1
    Please note that the enode URL changes every time you create a new instance with different parameters. You don't need to add "enode://pubkey@ip:port" to the static.json file. I recommend you delete everything and start over the process with the same genesis file and different empty datadirs. – galahad Jun 17 '16 at 15:13
  • 1
    I think we are really close now. Your suggestion with the static IP fix removed the letter error that was popping up all the time and made the true problem finally visible. Thank you for your time and effort. – mechanicum Jun 20 '16 at 7:58
3

First problem was the wrong syntax in the static-nodes.json as @galahad pointed out. Below is the correct one.

[
  "enode://abc13b392a70743a2c1226e84f0c1fbf00768d44854730db4745952d0c91efcba2fd8cc6b7df3ad68ecac99333560376b6888ac114e61c83c8d45b0a53b92223@10.222.6.87:30301",
  "enode://2520136e29c92473064edb44db63d7c4e2589bb3e0558524af8b0158e156d86e6c0e2ec8f4e372691626c44e184518c9b6a78557d613620d8939abab033c3a11@10.222.6.87:30302"
]

Second was the wrong networkID nodes were trying to connect with. After solving the above error it kept throwing networkID mismatch errors when trying to connect. It assigned a random int ID when the one I have was above max value. Getting networkID below max int value solved that problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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