Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Avoid dropped connections due to idle timeouts UNIX
Tiger only hintMy ISP is very agressive about killing stalled connections. When no data has gone across an open connection, the ISP kills the connection. This killed ssh connections to remote machines constantly, and I found myself having to reconnect several times an hour if I was working on a machine remotely.

Fortunately, OSX 10.4 uses OpenSSH 3.8, which can send a packet at a regular interval to see if a server is alive. In my situation, this has the side benefit of actually keeping the connection open, since it resets whatever inactivity timer my ISP uses. Setting it up is pretty simple. Add the following to your .ssh/config file:
Host *
    ServerAliveInterval 120
    ServerAliveCountMax 3 
This will send the server a message every 120 seconds, as per the ServerAliveInterval directive. The ServerAliveCountMax command tells it to kill the connection from the client end if the server hasn't responded after three messages (i.e. six minutes).
    •    
  • Currently 3.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[24,904 views]  

10.4: Avoid dropped connections due to idle timeouts | 9 comments | Create New Account
Click here to return to the '10.4: Avoid dropped connections due to idle timeouts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Avoid dropped connections due to idle timeouts
Authored by: mschaff on Dec 23, '05 07:29:48AM

Nice hint, but I'd be shopping for a new ISP.



[ Reply to This | # ]
10.4: Avoid dropped connections due to idle timeouts
Authored by: MRFreeze on Dec 23, '05 04:41:50PM

Unfortunately this is not an option for all of us. My ISP is the only high speed provider in my area.



[ Reply to This | # ]
10.3: Avoid dropped connections due to idle timeouts
Authored by: stereosubs on Jan 03, '06 06:29:44AM

This is a hint for those who read the machints story " 10.4: Avoid dropped connections due to idle timeouts " that don't have 10.4 or the new openssh (but do use X11).


I used to use 'top' to achieve this:

This technique has the added benefit of checking the top processes on a system at the same time. If you ssh into a host via X11, you can spawn another terminal that keeps an active connection. my old-reliable was

    xterm -e "top -s 120"

After logging in, running this command will open another window that will periodically show the top processes on that system.

NOTE: MacOSX's ssh disables X11 Forwarding by default:
So,either use "ssh -X hostname" or modify your ~/.ssh/config to contain these extra lines

( although I edit /etc/ssh_config to do this )

    Host *
    ForwardAgent yes
    ForwardX11 yes

PS: Unfortunately, ISPs in my area are more like monopolies. for about 6 months I had to tunnel my smtp traffic throughout my works VPN because port 25 was being filtered.

[ Reply to This | # ]

10.4: Avoid dropped connections due to idle timeouts
Authored by: wgscott on Dec 23, '05 09:32:52AM

Thanks for posting this. The timeouts give me a cracking migrane. This seems to be a quite common issue (ATT, PacBell, etc) so it is well worth a try.



[ Reply to This | # ]
10.4: Avoid dropped connections due to idle timeouts
Authored by: DEMON on Dec 23, '05 10:56:04AM

I had also this problem. I solved it in a different way. In system preferences under network I gave my connection an "ID DHCP-client" name. Somehow it worked.



[ Reply to This | # ]
10.4: Avoid dropped connections due to idle timeouts
Authored by: sjk on Dec 23, '05 08:00:20PM

I'm curious, where'd you find the idea to do that?



[ Reply to This | # ]
10.4: Avoid dropped connections due to idle timeouts
Authored by: Chage on Dec 25, '05 11:06:21PM

Nice Find.
Whilst I dont have an agressive ISP, if my connection gets reset, I hope this will gracefully close the ssh connection, rather than it dropping, and requiring a reset of th terminal to fix up the term issues it causes.



[ Reply to This | # ]
10.4: Avoid dropped connections due to idle timeouts
Authored by: ducasi on Dec 26, '05 01:30:57AM

I had that problem for a while, but it turned out to be my router that was not forwarding "keep-alive" packets, rather than the ISP.

In fact it's fairly difficult for an ISP to "drop connections", as it would need to keep state of all connections that are active and forge reset packets to make the connection fail.

(Or they could also fail to route keep-alive packets.)

Either way would be a very bad thing for an ISP to do.

I solved my problem by doing away with the separate router, and using my Mac as a router.



[ Reply to This | # ]
10.4: Avoid dropped connections due to idle timeouts
Authored by: dougw2112 on Dec 26, '05 05:58:04AM

You may know this already, and if you do then you can skip this comment.

You may have two events taking place here. 1) your ISP may be dropping you, I don't know anything about that, but 2) SSH by default disconnects the connection as a security feature. Most every SSH tool provides a keep alive function for just this reason. If you use emacs as an editor, turning on the "time" function is handy because it will pool the time every minute. Not perfect but it does provide some success.

dougw



[ Reply to This | # ]