Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot connect to static/trusted peers with --maxpeers 0 #3326

Closed
iciakky opened this issue Nov 23, 2016 · 2 comments · Fixed by #16189
Closed

cannot connect to static/trusted peers with --maxpeers 0 #3326

iciakky opened this issue Nov 23, 2016 · 2 comments · Fixed by #16189

Comments

@iciakky
Copy link

iciakky commented Nov 23, 2016

System information

Geth version: 1.5.2+ (from master)
OS & Version: Windows 10

Expected behaviour

when set --maxpeer 0, only the trusted/static peers can connect

Actual behaviour

when set --maxpeer 0, even trusted/static peers can NOT connect

Steps to reproduce the behaviour

  1. prepare static-nodes.js with one static node N you can connect to
  2. run geth with --maxpeers 1 --nodiscover
  3. make sure you can connect to N
  4. restart geth with --maxpeers 0 --nodiscover --verbosity 6
  5. you will see that N is removed from peers right after it's added, for "too many peers!"
    it could be caused by light clinet/server mode's implementation,
    which limit connections only by maxpeers in protocol manager/handler.

besides, there is a race condition for the maxpeers check in protocol manager/handler.
you can connect to more then one static nodes even with static-nodes.js and --maxpeers 1,
but you can not further add more static nodes with admin.addPeer().
(It will be removed for "too many peers!")

Partial output of geth

notice that what have been done to peer ceabe1b1b4fa9c88

I1122 16:17:14.634244 p2p/server.go:466] new task: static dial ceabe1b1b4fa9c88 163.172.189.38:8080
I1122 16:17:15.363159 p2p/server.go:524] <-posthandshake: trusted static dial conn ceabe1b1b4fa9c88 163.172.189.38:8080
I1122 16:17:15.365165 p2p/server.go:530] <-addpeer: trusted static dial conn ceabe1b1b4fa9c88 163.172.189.38:8080
I1122 16:17:15.366168 p2p/server.go:722] Added Peer ceabe1b1b4fa9c88 163.172.189.38:8080
I1122 16:17:15.366168 p2p/server.go:514] <-taskdone: static dial ceabe1b1b4fa9c88 163.172.189.38:8080
I1122 16:17:15.370183 p2p/peer.go:301] Peer ceabe1b1b4fa9c88 163.172.189.38:8080: Starting protocol eth/63
I1122 16:17:15.372188 p2p/peer.go:308] Peer ceabe1b1b4fa9c88 163.172.189.38:8080: Protocol eth/63 error: Too many peers
I1122 16:17:15.377213 p2p/peer.go:177] Peer ceabe1b1b4fa9c88 163.172.189.38:8080: protocol error: Too many peers (Too many peers)
I1122 16:21:12.601907 p2p/server.go:738] Removed Peer ceabe1b1b4fa9c88 163.172.189.38:8080 (Too many peers)
I1122 16:21:12.601907 p2p/server.go:546] <-delpeer: Peer ceabe1b1b4fa9c88 163.172.189.38:8080
@coeniebeyers
Copy link

I confirm this behaviour on geth 1.5.3, on geth 1.4.9, 1.4.10 and 1.4.11 the expected behaviour is still working correctly.

@coeniebeyers
Copy link

Any update on this? Parity explicitly allows this:

--reserved-peers FILE Provide a file containing enodes, one per line.
These nodes will always have a reserved slot on top
of the normal maximum peers. (default: None)
--reserved-only Connect only to reserved nodes. (default: false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants