Socket connection timeout over vpn

centos6networkingtimeoutvpn

I have a server running a largely default install of CentOS 6.4. It is behind a VPN and a firewall, neither of which are managed by me – they are managed by the hosting company.

When I leave an ssh client open for a long time without touching it (in cygwin from my desktop), eventually it freezes (Ctrl+C doesn't even work) and then after a much longer amount of time, it recovers but the ssh connection disconnects with a Connection Reset by Peer error.

Normally, I would not care about this, however: I have been developing a server application with a client GUI. The two applications do have a heartbeat between them. Today, I left them alone for under two hours and when I returned they had crashed. The server's error messages said:

java.io.IOException: Connection timed out
java.io.IOException: Broken pipe

The client's log said:

java.io.IOException: An established connection was aborted by the software in your host machine

When I returned I clicked the "reconnect" button on the client without restarting either application and they are working correctly again with no issues – so it's not like one of the applications ran out of resources or equivalent.

I think this is more of a ServerFault question than a StackOverflow question because of the similar behavior I have seen in my ssh connections. What could be causing this network timeout, and what can I do about it?

Best Answer

for the ssh just adjust the ssh keepalive session

for putty(Windows) on the properties under session click on the connection and under sending of null packets to keep session active you need to set seconds between keepalives to the desire seconds you want

for Linux You can find it under /etc/ssh/ssh_config

Host * ServerAliveInterval 300 ServerAliveCountMax 2

Probably the error "java.io.IOException: An established connection was aborted by the software in your host machine"

there's a lot of possible issue for this

first thing to look are the vpn and firewall some of the vpn use "vpn-idle-timeout" which Terminates any user's session when the session is inactive for the specified time and also take note that the Firewall also may or may not interact with other device using TCP Keep Alive packets.

another thing is on the Application side:

e.g Oracle web server's "HTTP-level keep-alive system"

This can tune the maximum number of connections that the server allows to wait at one time before closing the oldest connection in the Admin Console

but take note that

"If every request is allowed to keep the connection open indefinitely, the server can become overloaded with connections. On UNIX and Linux systems, this can lead to a file table overflow very easily"

you can check this documentation for reference

http://docs.oracle.com/cd/E19146-01/821-1834/gdpiq/index.html