Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two python scripts, which reside on different machines and are connected by a TCP connection. If the scripts do not share any data, they send dummy packets, so that the session is never idle for a long period (max 5s). For any reason the connection dies after about 2-3days.

Is there something like a maximum session time in linux, which just kills the socket? If so, how should I proceed? Recreate the connection once a day, set some value in /proc?

share|improve this question
Do the scripts die, or just the connection? How are they connected? Wired though a local switch, WiFi, ...? Any record in the system logs? Do your machines perhaps get IP addresses via DHCP, one lease expired and the IP address changed? – vonbrand Feb 6 '13 at 18:03
Just the connection dies. Both machines are servers with fixed IPs, connected over the internet. But now as you mention it: one of them is behind a Linksys E2000. No DHCP behind the router, but maybe the router breaks the connection. I will investigate the router's behaviour/config, thanks! – fiz Feb 6 '13 at 21:54

The problem will most likely be the NAT and session tracking being done by your Linksys router. I routinely have sessions up which last longer then a few days, depending on what I am doing the only thing which kills them is reloading the router (but I'm not using low-end routing gear).

One thing I note is that even if I do things to the Interfaces and routes on the boxes (including restart networking), once the changes are complete, terminal sessions continue.

One work around might be to set up a VPN so as to abstract the connection across your router.

share|improve this answer
I've changed my setup to VPN, but the problems continue. I'm now using the exception to perform a reconnect. So is there is no such thing like a maximum session timeout? If not I think I'll go for your answer, and the problem must be something else. – fiz Feb 16 '13 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .