Bitcoin Forum
December 04, 2016, 08:29:33 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Bitcoin v0.4.0 (Linux) stale connections handling  (Read 1364 times)
modrobert
Member
**
Offline Offline

Activity: 70


-"When the going gets weird, the weird turn pro."


View Profile WWW
October 26, 2011, 04:49:38 AM
 #1

I use an ISP which forces a new IP address via DHCP every 24 hours, and they are pretty big, roughly 2 million users in Thailand total.

When the IP address changes the Bitcoin client slowly drops all stale connections above 8 connections. This means I have to restart the Bitcoin client to make it go above 8 connections once every day.

If I skip restarting the client, the effect is probably worse for the network as a whole than me personally, since having lots of connections active benefits the Bitcoin transaction system.

Is there any way to fix this in the Bitcoin client to handle stale connections after IP address change better?

EDIT:

Forgot to mention I use Bitcoin v0.4.0 for Linux.

Need modchips? We accept BTC...
1480840173
Hero Member
*
Offline Offline

Posts: 1480840173

View Profile Personal Message (Offline)

Ignore
1480840173
Reply with quote  #2

1480840173
Report to moderator
1480840173
Hero Member
*
Offline Offline

Posts: 1480840173

View Profile Personal Message (Offline)

Ignore
1480840173
Reply with quote  #2

1480840173
Report to moderator
1480840173
Hero Member
*
Offline Offline

Posts: 1480840173

View Profile Personal Message (Offline)

Ignore
1480840173
Reply with quote  #2

1480840173
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
tcatm
Sr. Member
****
qt
Offline Offline

Activity: 337


View Profile
October 26, 2011, 01:12:04 PM
 #2

IIRC the problem is because your router is not closing those TCP connections correctly so as far as bitcoin is concerned those connections are still open.
Herbert
Hero Member
*****
Offline Offline

Activity: 488



View Profile WWW
October 26, 2011, 01:32:35 PM
 #3

I had linux client 0.4.0 running overnight for several times and never noticed a decrease in connections (Also getting new IP every 24hours). So indeed this looks more like a problem on your side, not a general issue.

www.bitcoinmonitor.net - Free payment notification via email, newsfeed, xpmm/jabber, url callback and full API access!
Send SMS with www.txt4coins.net! No registration, pay-per-use, full API access, bulk messages - All inclusive!
modrobert
Member
**
Offline Offline

Activity: 70


-"When the going gets weird, the weird turn pro."


View Profile WWW
October 26, 2011, 05:40:24 PM
 #4

IIRC the problem is because your router is not closing those TCP connections correctly so as far as bitcoin is concerned those connections are still open.

If that was the case, the Bitcoin client wouldn't go down from say 100+ connections to 8 open connections (as shown in the GUI status row) after IP address change, right?


I had linux client 0.4.0 running overnight for several times and never noticed a decrease in connections (Also getting new IP every 24hours). So indeed this looks more like a problem on your side, not a general issue.

Interesting, how many connections did the Bitcoin client report to have open when you tested this?

Might be worth noting that other software I use for mining (poclbm.py), irc, usenet and bittorrent does handle the IP address change without a problem.

I could easily write a script which kills and restart the Bitcoin client whenever the IP address changes, but that would be more of a workaround than actual fix.

UPDATE:

I've been checking the source code here:

https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L405

The functions ThreadGetMyExternalIP() and GetMyExternalIP() specifically. I guess the problem is related to how the IP address is cached when received from either IRC (Server IP: 92.243.23.21), or when the backup services dyndns.org and showmyip.com are used (Yes, to my surprise the Bitcoin client actually rely on these services hardcoded).

It seems these functions aren't called properly when my router get new IP address via DHCP, so no incoming connections can reach the host because the old IP address is used, only the 8 connections which are outgoing still reconnects ok after timing out.

Need modchips? We accept BTC...
Herbert
Hero Member
*****
Offline Offline

Activity: 488



View Profile WWW
October 27, 2011, 09:13:01 PM
 #5

I stand corrected.
Just did the following: Start up client, wait until ~150 connections are there, disconnect & reconnect router.
=> Client starts loosing connections and stays down at 8.

Sorry for being ignorant  Wink

www.bitcoinmonitor.net - Free payment notification via email, newsfeed, xpmm/jabber, url callback and full API access!
Send SMS with www.txt4coins.net! No registration, pay-per-use, full API access, bulk messages - All inclusive!
modrobert
Member
**
Offline Offline

Activity: 70


-"When the going gets weird, the weird turn pro."


View Profile WWW
November 06, 2011, 03:59:06 PM
 #6

Any Bitcoin developers care to fix this problem?

Need modchips? We accept BTC...
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
November 06, 2011, 05:55:57 PM
 #7

Any Bitcoin developers care to fix this problem?

Let me think... a problem that affects a small number of people... means you end up with 8 connections instead of more than 8... and has an easy, obvious workaround... and if fixed will be difficult to test thoroughly...

Not high on my priority list.

Things that ARE high on my priority list:

+ Getting the 0.5 release out the door
+ Improving initial startup and block download times
+ Solutions for wallet security and backup


How often do you get the chance to work on a potentially world-changing project?
modrobert
Member
**
Offline Offline

Activity: 70


-"When the going gets weird, the weird turn pro."


View Profile WWW
November 07, 2011, 11:21:01 AM
 #8

Ok, I'm testing the socks4 proxy function for now as a workaround.

Actually having more than 8 connections isn't important to me personally at all, I was under the impression it was for Bitcoin, can't find the post where I read that though.

Need modchips? We accept BTC...
Matt Corallo
Hero Member
*****
expert
Offline Offline

Activity: 751


View Profile
November 08, 2011, 02:44:29 AM
 #9

This has been an issue for a long, long time.  There are several bugs on the subject, but no one has ever bothered to fix it, because its really just not that big of a deal...anyway, patches welcome.

Bitcoin Ubuntu PPA maintainer - donate to me personally: 1JBMattRztKDF2KRS3vhjJXA7h47NEsn2c
http://bitcoinrelaynetwork.org maintainer
PGP ID: 07DF 3E57 A548 CCFB 7530  7091 89BB B866 3E2E65CE
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!