Bitcoin Forum
May 10, 2024, 11:45:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin v0.4.0 (Linux) stale connections handling  (Read 1552 times)
modrobert (OP)
Sr. Member
****
Offline Offline

Activity: 355
Merit: 284


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


View Profile
October 26, 2011, 04:49:38 AM
Last edit: October 26, 2011, 06:28:55 PM by modrobert
 #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.
1715341513
Hero Member
*
Offline Offline

Posts: 1715341513

View Profile Personal Message (Offline)

Ignore
1715341513
Reply with quote  #2

1715341513
Report to moderator
The trust scores you see are subjective; they will change depending on who you have in your trust list.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
tcatm
Sr. Member
****
qt
Offline Offline

Activity: 337
Merit: 265


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
Merit: 500



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 (OP)
Sr. Member
****
Offline Offline

Activity: 355
Merit: 284


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


View Profile
October 26, 2011, 05:40:24 PM
Last edit: October 27, 2011, 07:01:25 AM by modrobert
 #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.
Herbert
Hero Member
*****
Offline Offline

Activity: 488
Merit: 500



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 (OP)
Sr. Member
****
Offline Offline

Activity: 355
Merit: 284


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


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

Any Bitcoin developers care to fix this problem?
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


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 (OP)
Sr. Member
****
Offline Offline

Activity: 355
Merit: 284


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


View Profile
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.
Matt Corallo
Hero Member
*****
expert
Offline Offline

Activity: 755
Merit: 515


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 Core, rust-lightning, http://bitcoinfibre.org etc.
PGP ID: 07DF 3E57 A548 CCFB 7530  7091 89BB B866 3E2E65CE
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!