Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

At this moment, blockchain.info has over 1,900 nodes connected to their bitcoin client.

I have been running an m1.small ubuntu 12.04 server and bitcoind for ~4 days straight now with no reboots. My bitcoind client still only shows ~60 connections maximum when performing a "./bitcoind getinfo" command.

How can I achieve 1,000+ connections to my bitcoind client? And is it "worth it" in your opinion?

EDIT: I have re-started my bitcoind client with the -maxconnections=1000 and -timeout=15000 parameters but after ~12 hours of running bitcoind, the number of connections is only up to ~40. And I don't seem to be maxing out my CPU, RAM, or bandwidth just yet.

EDIT 2: I have not seen a "connected time" over 8 hours in the list provided by blockchain.info so that tells me they must restart their server every 8 hours or so. Either that, or connections drop and refresh after 8 hours? I am beginning to think that blockchain.info keeps track of IP addresses running bitcoin in a database of sorts... and forefully connects to them every time their bitcoind reboots. Am I right?

share|improve this question
2  
Blockchain runs multiple bitcoind nodes and the networking components were also modified to use boost::asio rather posix sockets. you should be able to get at least 1024 connections with standard bitcoind though. –  Ben Reeves Mar 4 '13 at 19:22
    
Any idea on what might be holding me back from achieving 1,024 connections on my bitcoind? I don't seem to be maxing out my CPU, RAM, or bandwidth just yet. –  user3145 Mar 4 '13 at 21:53

4 Answers 4

up vote 6 down vote accepted

The bitcoind client has a maxconnections configuration option. The client launched With -maxconnections=N will allow up to N incoming connections to be established simultaneously.

Perhaps you may need to increase the connection timeout for that many connection attempts from a single (possibly underpowered) node. Perhaps set it to like 15 seconds (15000 ms).

-timeout= Specify connection timeout in milliseconds (default: 5000)

[Edit: Pieter Wuille's answer gets you further there. -addnode will let you force new outgoing conections to nodes when you have their IP addresses.]

share|improve this answer
    
I will re-start my bitcoind client now with the timeout increased to 15 seconds as suggested as well as the -maxconnections=1000 and get back to you. –  user3145 Mar 4 '13 at 21:54
1  
So after 7 hours of running bitcoind with a 15 second timeout and 1,000 max connections.. I was at 32 connections at one point but have now dropped to 28, so I doubt adding the maxconnections or the timeout variable did much at all unfortunately. In fact I think it may have hindered the number of connections I would normally have after 7 hours. –  user3145 Mar 5 '13 at 5:16

Bitcoin by default will not make more than 8 outgoing connections, and -maxconnections only controls how many incoming connections you allow. Feel free to set this higher, but it will take time before others connect to you in large numbers.

Please don't change this, as there is no need. Connectable peers on the network are a scarce resource, and essential to the decentralization. If people go try connect to all of them like some sites do, we'll very quickly run out.

In case you're a merchant or miner, you perhaps want to set up a few fixed connections to trusted others (see the -addnode command line/config option), but having more connections does not mean stronger verification (the reference client always verifies everything) or even faster relaying (as you'll slow down by distributing new blocks and transactions to all your peers). It is mostly a matter of providing a server to the network.

share|improve this answer
1  
After 4 days of running my box with -maxconnections=1000, I was still only at ~50 connections. I have not seen a "connected time" over 8 hours in the list provided by blockchain.info so that tells me they must restart their server every 8 hours or so. Either that, or connections drop and refresh after 8 hours? –  user3145 Mar 5 '13 at 18:23
    
I'm sure they have a custom infrastructure that creates thousands of outgoing connections. Bitcoind never creates more than 8. As I said, there is no need for more. –  Pieter Wuille Mar 5 '13 at 23:27

The given answers don't answer the question. Even though it might not makes sense to achieve a thousand connections, here's how to do that on Debian. You want to make some slightly changes in the code and recompile bitcoind:

Get required packages for compiling:

$ aptitude install git make build-essential libssl-dev libboost-all-dev libdb-dev libdb++-dev libminiupnpc-dev

Clone the git repository (make sure the version is the most recent branch):

$ cd /usr/src
$ sudo git clone -b 0.8.4 https://github.com/bitcoin/bitcoin
$ cd bitcoin/src

Edit the net.cpp file:

@@ -27,7 +27,7 @@
 using namespace std;
 using namespace boost;

-static const int MAX_OUTBOUND_CONNECTIONS = 8;
+static const int MAX_OUTBOUND_CONNECTIONS = 1000;

 bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);

@@ -1533,7 +1533,7 @@
             OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
             MilliSleep(500);
         }
-        MilliSleep(120000); // Retry every 2 minutes
+        MilliSleep(5000); // Retry every 5 seconds
     }
 }

1.) By changing MAX_OUTBOUND_CONNECTIONS, the client will go on connecting until it reaches 1000 proactive connections.

2.) By changing the sleep timeout new connections are tried more frequently.

Compile and install bitcoind:

$ sudo make -f makefile.unix
$ sudo mv bitcoind /usr/bin

Don't forget to set the maxconnections in bitcoin.conf:

maxconnections=1000

Start bitcoind and your done. The client will make lots of connections really fast.

Disclaimer: As Pieter Wuille pointed out, it can harm the network to run a modified client like this one. Please use this solution for research purposes only and not as a permanent solution.

share|improve this answer
3  
I don't want to downvote because you're indeed actually answering the question, but I really strongly want to stress that doing this is a horrible idea and unnecessary. See my answer for why. –  Pieter Wuille Aug 25 '13 at 23:37
    
I edited my answer. –  MorbZ Aug 26 '13 at 1:09
    
@Pieter Wuille: How do you want to stop people from exploiting the Bitcoin network? Just telling them "hey, you bad boys, don't do this or that"? That's not going to work... –  Kozuch Dec 16 '13 at 10:39
1  
I'm not trying to stop bad guys - they're a fact of life, and I'm sure we can deal with a few. What I want to avoid is people incorrectly assuming that more connections is better for them and/or the network. –  Pieter Wuille Dec 16 '13 at 23:39
    
This is the real answer! –  Felipe Micaroni Lalli Mar 12 at 11:29

Why do you need 1,000+ connections?

By default bitcoind cannot have more than 125 connections. You need to start bitcoind with the parameter -maxconnections=<n> or set maxconnections=<n> in bitcoin.conf to be able to connect to more peers.

share|improve this answer
4  
Why?! Why not should be the real question! If you must know, I want to have the most verified blockchain in the world. –  user3145 Mar 4 '13 at 19:06
2  
"The most verified"? That makes no sense. Every node at the same block height and block hash is equal. And yours may have a blockchain fork that eventually becomes orphaned. –  Stephen Gornick Mar 4 '13 at 20:38
5  
Sorry for the typo, I'm not up to speed on the entire bitcoin lexicon just yet. If not the most verified, then I want to be the fastest at recognizing new transactions. That is what I meant. –  user3145 Mar 4 '13 at 21:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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