Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
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
1  
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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.