November 14, 2005

adsl connection timeouts (and fix)

recently, when we got the internetconnection for our new office we suddenly experienced time-outs of ssh sessions. when the connection was idle for about 30 minutes the connection hung. the problem was not with our computers or servers because the problem did not exists on our other internetconnection which we are still able to use with no problems at all.

we tried calling the kpn direct-adsl (=planet?) helpdesk after an hour or so we finally got someone technical on the phone. he first tried altering the speed from 8 to 3 Mbit but that didn't solve the problem. then he sent us a splitter that wasn't installed because we didn't need a phonenumber on the line. that also did not solve the problem.

in the mean time we found a workaround for the ssh problem by setting some variable in /etc/ssh/ssh_config.conf, i believe it was ClientAliveInterval, i'll check that.
a keepalive packet is sent after x seconds and on our connection that does keep the sessions alive.

besides ssh we also use mysql connections quite a lot and they also hung after 30 minutes. that made us have to shutdown mysqlcc and restart it several times a day.

but, sit back in your chair, there is an even better solution if you are experiencing time-outs on your internet connection. that solution works at the tcp level so all applications and protocols benefit from it.

if you do the following (in my case under debian linux)

$ cat /proc/sys/net/ipv4/tcp_keepalive_time

you'll see that the keepalive time is currently at 7200 seconds, or 2 hours.
that means that the computer only tries to check if the connection is still alive after 2 hours. if that time our connection was longtime gone so that didn't make sense.

if we set that time to, for instance 5 minutes (300 sec), the computer will sent tcp keepalive packets every 5 minutes (to every connection on every server) and as a result our connection will never die. and indeed, our connection now workes like a charm.

you can set the interval to 300 secs by adding the following line to


restart your computer and the sessions will never time-out :)

there's is a minor sidenote: if your connection is down/broken for a longer period than the above setting your computer will not be able to keep the connection intact. in theory that is possibly if no tcp packets are sent during the connection downtime. maybe you can try to figure out the best time (20 mins?) but our internetconnection almost never is down so that's not a problem to us.

i'd appreciate it if you drop a note if you find this information usefull
Posted 12 years, 7 months ago on November 14, 2005

geen commentaar mogelijk bij deze post