discussion on number of outbound connections (limited to 8) #962

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:outbound-connections changing 1 files +4 −4
  1. Diapolo commented at 6:23 PM on March 20, 2012: none

    old behaviour:

    • if -maxconnections is 0 or negative, no connection to the network was established at all
    • the maximum number of connections was in range 0 to 8 (125 was unused)

    new behavior:

    • if -maxconnections is 0 or negative, MIN_OUTBOUND_CONNECTIONS will be used to ensure connectivity
    • if -maxconnections is unset Gavins intended default of 125 is used
    • if -maxconnections is > MAX_OUTBOUND_CONNECTIONS, MAX_OUTBOUND_CONNECTIONS is used

    Perhaps the value of MAX_OUTBOUND_CONNECTIONS and MIN_OUTBOUND_CONNECTIONS should be refined further.

    I tested the changes on Windows and can confirm they work. Oh and I think this "bug" or let's say strange behaviour was introduced by Gavins commit to set defaults to 125. I was so sure, that I saw more than 8 connections before 0.6, but no one seems to have noticed?

  2. fix for number of outbound connections (was limited to 8) e35f26b001
  3. luke-jr commented at 6:28 PM on March 20, 2012: member

    I think you are confusing connections and outbound connections?

  4. Diapolo commented at 6:35 PM on March 20, 2012: none

    Outbound connections are the real IP connections from the "internet" to my PC running the node, the value that is shown in Bitcoin-Qt if you hover the connection quality symbol.

    I don't say the commit is perfect, perhaps it includes errors, but it does what I wrote above ;).

  5. sipa commented at 6:37 PM on March 20, 2012: member

    Outbound connections is the number of connections your node makes to other nodes. Inbound connections is the number of connections your node receives. What bitcoin-qt shows in the hover text the sum of these two, and that is what -maxconnections limits.

  6. Diapolo commented at 6:41 PM on March 20, 2012: none

    MAX_OUTBOUND_CONNECTIONS was set to 8 in the code and I saw that a maximum of 8 TCP connections were established no matter, if -maxconnections was set > 8. So the number of 125 was not reached, right? With my changes this is fixed and the value of -maxconnections works. So perhaps I missunderstood some wordings, but I think there is a problem here with the original code.

  7. gavinandresen commented at 6:43 PM on March 20, 2012: contributor

    NACK: we don't want to increase the number of outbound connections past 8. 8 is plenty.

  8. sipa commented at 6:45 PM on March 20, 2012: member

    If you do not get more than 8 connections, it means that you don't accept incoming connections (firewall issue, typically).

    -maxconnections is not supposed to change the number of outbound connections (you don't need more than 8, and the number of nodes that accept connections is limited, so we shouldn't overuse these).

  9. Diapolo commented at 6:53 PM on March 20, 2012: none

    Seems I missunderstood something, but perhaps someone can explain to me, why I only see a max. of 8 "active connections to Bitcoin network" in the client and why this changes with my commit and why there is a default of 125 in the GetArg-call for -maxconnections used in a comparison with nInbound?

  10. luke-jr commented at 6:54 PM on March 20, 2012: member

    You'll see more if your internet connection properly accepts inbound connections...

  11. Diapolo commented at 6:57 PM on March 20, 2012: none

    @luke-jr I see more, if this commit is active ... does "active connections to Bitcoin network" sum inbound and outbound as that could explain the numbers, because there are more outbound connections active.

  12. TheBlueMatt commented at 7:00 PM on March 20, 2012: member

    Switching to making it easy for people to make a ridiculous number of outbound connections (really, anything more than 8) just makes it easy to DoS the network. Yea its not hard, but you have to atleast be able to compile bitcoin, whereas making it easy to do with just command line flags opens us up to "Your node may be under-performing (because your connection bar doesnt have full bars!) you should set -maxconnections or -outboundconnections high to get full bars". See; the -hubmode crap that was popular a while ago... Note: the connection bar wont let you have full bars without INCOMING connections to encourage people to properly forward their ports, not to make them find more outgoing connections.

  13. sipa commented at 7:02 PM on March 20, 2012: member

    If you only see 8 connections, it is because you only have 8 outbound connections (which is limited to 8, and it should), and no incoming connections (because of a firewall issue).

    Your patch changes the number of outgoing connections. Yes this will mean more total connections as well, but that is not the correct way to achieve it. The solution is fixing your firewall.

  14. Diapolo commented at 8:37 PM on March 20, 2012: none

    One thing, which was a faulty firewall configuration (instead of allowing 8333 as local port, I chose remote port) on my side is fixed by a reconfiguration (thanks for the hint).

    And I now understand that only a maximum of 8 outbound connections is wanted per design of the client and to make it harder to DoS the BC network.

    What I still don't understand is the real value of the -maxconnections setting and why the default is 125. If a dev would be so kind and help me in my learning process :).

  15. in src/net.cpp:None in e35f26b001
    1340 | @@ -1340,8 +1341,7 @@ void ThreadOpenConnections2(void* parg)
    1341 |                  BOOST_FOREACH(CNode* pnode, vNodes)
    1342 |                      if (!pnode->fInbound)
    1343 |                          nOutbound++;
    1344 | -            int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;
    1345 | -            nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));
    


    Diapolo commented at 8:40 PM on March 20, 2012:

    This is the hard-limit for outbound connections, right? It's possible to disable them with -maxconnections=0 or negative vaules. But that line could as well look like this, right?

    int nMaxOutboundConnections = min(MAX_OUTBOUND_CONNECTIONS, (int)GetArg("-maxconnections", MAX_OUTBOUND_CONNECTIONS));

  16. grue0 commented at 11:57 PM on March 20, 2012: none

    @rebroad storage and network connections are two very different things. as more peers join the network, it actually becomes easier to broadcast your connection, not harder.

  17. Diapolo commented at 6:38 AM on March 21, 2012: none

    My intention is to understand and learn, so I looked in https://en.bitcoin.it/wiki/Satoshi_Client_Node_Connectivity for an explanation and there it's stated: "Outbound Limiting

    ... The first thing the loop does is count the number of outbound connections, and if the maximum has been reached (8 or -maxconnections), then it goes into a 2 second delay loop until the count is below the max."

    That code is in ThreadOpenConnections2 and I'm asking, if the wiki is obsolete or the code has a bug, because -maxconnections will never be > 8, because of "min(8, (int)GetArg("-maxconnections", 125)" and will allow to disable outbound connections completely if you set -maxconnections=0 or < 0.

    Inbound connections are handled via ThreadSocketHandler2 and I should simply remove that change and we can safely ignore that in the discussion from now on :).

  18. rebroad commented at 8:25 AM on March 21, 2012: contributor

    @gruez Ok, so if the network became smaller then nodes might need more than 8 connections?

    With my ISP I'm not allowed incoming connections. Is the max of 8 always going to be sufficient for nodes that will never be able to receive incoming connections?

  19. Diapolo commented at 5:50 PM on March 21, 2012: none

    I let this one open for another day or two and then close it! Till then more comments are welcome :).

  20. sipa commented at 9:26 PM on March 21, 2012: member

    Can you please explain in words what this patch is supposed to do? I don't see any problem with the existing behaviour.

  21. Diapolo commented at 10:01 PM on March 21, 2012: none

    The patch does not do, what it should do, because my FW didn't allow incoming connections from the outside, which limited the total number of connections for my node to 8 (and these were outbound). 8 is perfectly fine and I read in the Wiki that's defined and wanted behaviour.

    What I don't understand is, why GetArg("-maxconnections", 125) is used in the function ThreadOpenConnections2 used for managing outbound connections, because it's not possible to go above 8 for outbound.

    You use -maxconnections for out- and inbound summed up, right?

  22. sipa commented at 10:16 PM on March 21, 2012: member

    Because if you specify -maxconnection=4, you do not want more than 4 connections, and a fortiori not more than 4 outgoing connections.

  23. Diapolo commented at 10:28 PM on March 21, 2012: none

    It takes it's time but okay I see ... so 125 as default for in- and outbound connections with a hard limit of 8 for outbound and the possibility to lower this further.

  24. gavinandresen closed this on Mar 22, 2012

  25. suprnurd referenced this in commit f678ea48bd on Dec 5, 2017
  26. ptschip referenced this in commit b23d967c25 on Feb 13, 2018
  27. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me