Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ShadowOfHarbringer on May 24, 2011, 01:13:52 PM



Title: [FEATURE REQUEST/BUG REPORT] Limit maximum number of connections to X
Post by: ShadowOfHarbringer on May 24, 2011, 01:13:52 PM
Hello,

I'm having theoretically unimportant but practically problematic small problem with the main bitcoin client: it produces too many connections to external clients and clogs up my bandwidth.

On my 2Mbit broadband home connection, after the client passes 100 connections, most of webpages becomes unreachable. Yeah, i know it is a weak broadband because it becomes clogged easily, but still. (For bittorrent it usually takes about 150 connections to fill the pipe up)

I would like to propose adding "-max-connections=X" command line argument and/or "max-connections=X" directive to bitcoin.conf.

----
EDIT:

It seems that actually it is UPnP support in the client that causes this. So this is more of a [BUG REPORT] than ft. request .


Title: Re: [FEATURE REQUEST] Limit maximum number of connections to X
Post by: sandos on May 24, 2011, 01:26:23 PM
I'm pretty sure the client only opens 8 connections normally?


Title: Re: [FEATURE REQUEST] Limit maximum number of connections to X
Post by: ShadowOfHarbringer on May 24, 2011, 01:27:38 PM
I'm pretty sure the client only opens 8 connections normally?

Apparently not anymore.

It goes up and up and up - it reached to 117 connections untill i killed it because it filled my bandwidth pipe.
Tested on multiple computers on Linux.

Also, It does so even after all blocks are downloaded.


Title: Re: [FEATURE REQUEST] Limit maximum number of connections to X
Post by: Garrett Burgwardt on May 24, 2011, 01:37:34 PM
Try running with -noupnp?


Title: Re: [FEATURE REQUEST] Limit maximum number of connections to X
Post by: ShadowOfHarbringer on May 24, 2011, 01:55:51 PM
Try running with -noupnp?

UPnP is offline on my router, i have DMZ set up though to the comp with Bitcoin currently.
But why should UPnP affect number of connections with external hosts ?

----
I am trying running bitcoin with "-noupnp" now, i will give you update in few minutes.

----
EDIT:

Yup, you were right -noupnp seems to have fixed it.

So this should be more like [BUG REPORT] than [FEATURE REQUEST].


Title: Re: [FEATURE REQUEST] Limit maximum number of connections to X
Post by: Pieter Wuille on May 24, 2011, 02:00:21 PM
It will not make more than 8 outgoing connections, but unless you supply -nolisten, it will listen for incoming connections independently. Maybe you just want to use -nolisten?


Title: Re: [FEATURE REQUEST] Limit maximum number of connections to X
Post by: ShadowOfHarbringer on May 24, 2011, 02:16:46 PM
It will not make more than 8 outgoing connections, but unless you supply -nolisten, it will listen for incoming connections independently. Maybe you just want to use -nolisten?

But I do want it to listen.

Without listening it is hard/slow for the client to make many external connections. With listening it is instant.

But the actual problem is broken UPnP support, so the matter is clear now. The older versions weren't affected because there was no UPnP at all in them.


Title: Re: [FEATURE REQUEST/BUG REPORT] Limit maximum number of connections to X
Post by: Matt Corallo on May 24, 2011, 03:05:52 PM
Wow, wow wow.  Hold on there.  UPnP has nothing to do with this.  First of all, to answer your original question, you can simply use -maxconnections=XX to limit max connections (default is 125), this has been in the client for quite some time. 
-noupnp actually ends up working the same way as -nolisten in that with UPnP enabled (which it is not, by default, unless you built yourself with USE_UPNP=1) your router will forward your connections properly allowing you to get more than 8 by accepting incoming connections.  -nolisten will end up doing the same thing by rejecting incoming connections.  What you should do is leave UPnP on (and/or forward the ports manually) and limit your connections to something that works for you, helping the network which has recently become very hard to bootstrap and make initial connections due to the massive number of people running nodes which do not accept incoming connections and/or do not have their ports forwarded properly.


Title: Re: [FEATURE REQUEST/BUG REPORT] Limit maximum number of connections to X
Post by: Garrett Burgwardt on May 24, 2011, 03:08:59 PM
Wow, wow wow.  Hold on there.  UPnP has nothing to do with this.  First of all, to answer your original question, you can simply use -maxconnections=XX to limit max connections (default is 125), this has been in the client for quite some time. 
-noupnp actually ends up working the same way as -nolisten in that with UPnP enabled (which it is not, by default, unless you built yourself with USE_UPNP=1) your router will forward your connections properly allowing you to get more than 8 by accepting incoming connections.  -nolisten will end up doing the same thing by rejecting incoming connections.  What you should do is leave UPnP on (and/or forward the ports manually) and limit your connections to something that works for you, helping the network which has recently become very hard to bootstrap and make initial connections due to the massive number of people running nodes which do not accept incoming connections and/or do not have their ports forwarded properly.

Ah, my mistake then :) I suggested that as a guess, didn't mean to pose as someone who knew what they were talking about :P


Title: Re: [FEATURE REQUEST/BUG REPORT] Limit maximum number of connections to X
Post by: ShadowOfHarbringer on May 24, 2011, 03:44:09 PM
Wow, wow wow.  Hold on there.  UPnP has nothing to do with this.  First of all, to answer your original question, you can simply use -maxconnections=XX to limit max connections (default is 125), this has been in the client for quite some time. 

Hmmm...

Too bad that this doesn't show up when i do # bitcoin --help.
Otherwise i wouldn't start this topic.

-noupnp actually ends up working the same way as -nolisten in that with UPnP enabled (which it is not, by default, unless you built yourself with USE_UPNP=1)

Weird. I'm using the pre-built bitcoin binary version 0.3.20. Is it built with UPnP support then ?
If not, then how disabling UPnP could have fixed it ?

your router will forward your connections properly allowing you to get more than 8 by accepting incoming connections.  -nolisten will end up doing the same thing by rejecting incoming connections. 

Why should disabling UPnP make the client reject connections ? This is weird. Shouldn't this be considered a bug ?

What you should do is leave UPnP on (and/or forward the ports manually)

I have forwarded the ports manually... I said i have DMZ set up.
Also, UPnP is disabled on my router anyway (i consider it to be unnecessary security risk), so enabling or disabling UPnP should have no effect whatsoever.


Title: Re: [FEATURE REQUEST/BUG REPORT] Limit maximum number of connections to X
Post by: Matt Corallo on May 24, 2011, 03:48:51 PM
Weird. I'm using the pre-built bitcoin binary version 0.3.20. Is it built with UPnP support then ?
If not, then how disabling UPnP could have fixed it ?
0.3.20 doesn't have UPnP support at all.  -noupnp does...nothing at all in 0.3.20.
That said, in recent time, bootstrapping and initial connections on the network have become very, very slow and random , which is probably exactly what you are seeing.

Why should disabling UPnP make the client reject connections ? This is weird. Shouldn't this be considered a bug ?
Thats not about the client, that is about the router.  If UPnP is on (on Bitcoin and your router), it will be possible to get incoming connections, whereas if its off (and you don't have your ports manually forwarded) there is no way for any application to receive incoming connections.

I have forwarded the ports manually... I said i have DMZ set up.
Also, UPnP is disabled on my router anyway (i consider it to be unnecessary security risk), so enabling or disabling UPnP should have no effect whatsoever.
Yep, as does using UPnP options in 0.3.20 ;).