Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: o on November 24, 2011, 02:44:46 PM



Title: Maximum number of connections in bitcoin client
Post by: o on November 24, 2011, 02:44:46 PM
I have tried to see how many active client nodes in the network. By running it for few days, the maximum number of connections I get is around 900.

So is it truely the size of bitcoin network at any moment? It is a bit weak in my opinion, isn't it?


Title: Re: Maximum number of connections in bitcoin client
Post by: slush on November 24, 2011, 02:50:17 PM
Not every client is running on public port and not every client is willing to talk with you when you'll try to connect them. For example my pool server is rejecting new connections when it reaches some number to prevent overloading.


Title: Re: Maximum number of connections in bitcoin client
Post by: Steve on November 24, 2011, 02:51:01 PM
900!  The most I've ever seen is around 150 and that's after running for several weeks (and usually it hovers around 100).  What version are you running?  Is there an option to increase the number of connections it tries to maintain?


Title: Re: Maximum number of connections in bitcoin client
Post by: slush on November 24, 2011, 02:53:28 PM
net.cpp, version 0.3.24:
Code:
if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
       closesocket(hSocket);

* yes, there's -maxconnection switch so user can adjust how many connections he want to keep
* when this number is reached, new connections are dropped


Title: Re: Maximum number of connections in bitcoin client
Post by: o on November 24, 2011, 03:12:55 PM
I have tried to see how many active client nodes in the network. By running it for few days, the maximum number of connections I get is around 900.

So is it truely the size of bitcoin network at any moment? It is a bit weak in my opinion, isn't it?

A pool certainly have many connections so you set a limit yourself, but I would consider most client is the standard version that does not reach the limit.

EDIT: BTW, what is the normal maximum number of connections you get now and at the time you start the pool.

net.cpp, version 0.3.24:
Code:
if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
       closesocket(hSocket);

* yes, there's -maxconnection switch so user can adjust how many connections he want to keep
* when this number is reached, new connections are dropped

Yes, both maxconnections and MAX_OUTBOUND_CONNECTIONS needs to set to a very large number.


Title: Re: Maximum number of connections in bitcoin client
Post by: P4man on November 24, 2011, 03:19:36 PM
Hmm..? Ive never seen more than 8 connections. I am behind 2 NATs though, I assume that has something to do with it..


Title: Re: Maximum number of connections in bitcoin client
Post by: slush on November 24, 2011, 03:23:38 PM
EDIT: BTW, what is the normal maximum number of connections you get now and at the time you start the pool.

Pool has only custom number in MAX_OUTBOUND_CONNECTION to make building p2p network faster after startup, but I'm using default maxconnections. As pool node is (obviously) permanent and almost without downtime, I have 125 connections all the time. After I moved pool to another IP, pool reached outbound connections pretty easily (in few hours), but it took few days until clients resolved new IP and 125 slots got filled.

Afaik, number of actively listening nodes is decreasing, but there are still thousands of them. Unfortunately I don't remember site which is crawling them and make graphs with timeline.


Title: Re: Maximum number of connections in bitcoin client
Post by: slush on November 24, 2011, 03:24:25 PM
Hmm..? Ive never seen more than 8 connections. I am behind 2 NATs though, I assume that has something to do with it..

Yes, MAX_OUTBOUND_CONNECTIONS in default client is 8 and because you're behind nat, other clients cannot open connection to you. However 8 connections is enough for normal client node.


Title: Re: Maximum number of connections in bitcoin client
Post by: piuk on November 24, 2011, 03:27:06 PM
The standard bitcoin client will likely not connect to over 1000 nodes as it's limited by select()'s fd_set size of 1024. I'm not sure if this is true of windows. My client, which uses kqueue, has connected to over 5000 nodes at once.


Title: Re: Maximum number of connections in bitcoin client
Post by: o on November 24, 2011, 03:40:36 PM
Afaik, number of actively listening nodes is decreasing, but there are still thousands of them. Unfortunately I don't remember site which is crawling them and make graphs with timeline.

This one? http://bitcoinstatus.rowit.co.uk/

Hmm..? Ive never seen more than 8 connections. I am behind 2 NATs though, I assume that has something to do with it..

Yes, MAX_OUTBOUND_CONNECTIONS in default client is 8 and because you're behind nat, other clients cannot open connection to you. However 8 connections is enough for normal client node.

8 connections is certainly more than enough if it is completely random, but it is a bit small in real case I think.

The standard bitcoin client will likely not connect to over 1000 nodes as it's limited by select()'s fd_set size of 1024. I'm not sure if this is true of windows. My client, which uses kqueue, has connected to over 5000 nodes at once.

I think it is the right reason since my connection never over 1000, I have suspected that there is some 1024 but none of it in the source codes. So it should be the system limit. It is build in ubuntu.


Title: Re: Maximum number of connections in bitcoin client
Post by: slush on November 24, 2011, 03:42:11 PM
This one? http://bitcoinstatus.rowit.co.uk/

Exactly. There's drop from ~60k nodes (all time history of charts) to ~40k nodes. Many people are saying that it's an indicator for bitcoin population and decreasing nodes == bitcoin rejection.

OT: I must say that I don't think so. From my neighborhood I'm the only one person who's using official client on my personal computer and it's mostly just because it's configured as "trusted node" for pool :-). Other people around me are starting to use web wallets because they have many benefits for common users (like instant access from everywhere) and also because maintaining full blockchain on personal computers and notebooks is simply annoying. Thanks to this, I believe that although count of bitcoin nodes is slightly decreasing, bitcoin population is still increasing, they just don't run official client, thus they're off the statistics.

Totally OT: As maintaining blockchain is going to be harder and harder, I believe that people will switch to lightweight clients like electrum - clients which don't handle even blockheaders, just private keys. It's great way to be almost completely safe (in contrary of web wallets) and not burn own computer while receiving transaction only once a week.


Title: Re: Maximum number of connections in bitcoin client
Post by: bitpop on January 04, 2014, 05:02:15 PM
I keep seeing two numbers, is it 8 or 125?


Title: Re: Maximum number of connections in bitcoin client
Post by: ajas on January 04, 2014, 09:22:58 PM
This one? http://bitcoinstatus.rowit.co.uk/

Exactly. There's drop from ~60k nodes (all time history of charts) to ~40k nodes. Many people are saying that it's an indicator for bitcoin population and decreasing nodes == bitcoin rejection.


As far as I see bitcoinstatus.rowit.co.uk is not updated any more.
The graphs last until October. (I dont know which year).


Title: Re: Maximum number of connections in bitcoin client
Post by: Shawshank on January 04, 2014, 09:34:29 PM
I keep seeing two numbers, is it 8 or 125?

By default, if the value on the bottom right side of Bitcoin-Qt says "8 connections to the Bitcoin network", you are most likely behind a firewall and you are not accepting incoming connections. In that case, you are acting like a leech and you are just putting burden on the network.

Normally, if the message at the bottom right side is something higher than 8 connections, you are contributing to the network by accepting incoming connections.

I keep a Bitcoin-Qt node running non-stop and I have never reached 90 active connections. Apart from the configuration, I believe it also depends on the upstream speed of your network and the processing capability of your machine.



Title: Re: Maximum number of connections in bitcoin client
Post by: bitpop on January 05, 2014, 04:31:31 AM
Sweet I'm trying to get 1000 connections


Title: Re: Maximum number of connections in bitcoin client
Post by: spin on January 06, 2014, 03:09:00 PM
Checkout: http://getaddr.bitnodes.io/


Title: Re: Maximum number of connections in bitcoin client
Post by: bitpop on January 06, 2014, 04:45:00 PM
I just launched nodes in nyc and ams
Sfo and Asia coming


Title: Re: Maximum number of connections in bitcoin client
Post by: doolittle on January 20, 2014, 02:37:10 PM
How is it possible to increase max_outbound_connections?
I want to increase the speed of the blockchain download.
So far I only have 8. BTW: can I also use the same options with dogecoin-client?
Looks exactly the same as Satoshi-Client.


Title: Re: Maximum number of connections in bitcoin client
Post by: Dr.Bob on March 25, 2014, 11:03:26 AM
Code:
net.cpp
Line 40 > static const int MAX_OUTBOUND_CONNECTIONS = 8;

https://github.com/bitcoin/bitcoin/blob/fc5d85c4bbb5fd5964117d4faf698ef2bf4ec634/src/net.cpp#L40 (https://github.com/bitcoin/bitcoin/blob/fc5d85c4bbb5fd5964117d4faf698ef2bf4ec634/src/net.cpp#L40)

Maybe it helps  ;D