netstat shows connection ESTABLISHED although client is dead.

Hi,

I have an issue with a client/server app where the Server is running under 1.4.2_04 on Solaris 9 using NIO and in this case the Client is connecting in from a Windows XP machine using standard Sockets.

If I bring up a selection of clients, I can see the connections in the ESTABLISHED state using netstat on the Solaris Server.

If I kill these clients, I see this as "Connection reset by peer" IOException on the Server and handle it gracefully.

However, very intermitantly (i.e. once a day while trying to replicate the problem), I can kill a client (ctrl-C) and netstat on the Server still shows the connection as ESTABLISHED. I can even reboot the client machine and the Server still shows the connection as ESTABLSHED. While the Client machine is down, the connection thinks it's ESTABLISHED to an IP address that is no longer accessable. This eventually ties up all the available sockets on the server (the max connected clients is configurable within the Server application) and the Server application has to be restarted to free them.

Does anyone have any idea what might be causing this issue. We only see it on Solaris and we port to most platforms.

Thanks for any help,

Rich.

Message was edited by:

richJTS

[1283 byte] By [richJTSa] at [2007-11-26 16:39:13]
# 1

A connection stays established until something happens to un-establish it. If the server doesn't detect the dead client neither will TCP. Any serious TCP server must employ read timeouts to detect dead clients, and it should close the socket on any IOException including the timeout exception. You could also enable TCP keepalive at the server, which will limit the duration of this problem to two hours, which is at least something, albeit not much. Ideally the application protocol should also contain regular pings in one or both directions.

ejpa at 2007-7-8 23:06:04 > top of Java-index,Archived Forums,Socket Programming...
# 2
Thanks ejp,Plenty to think about there. I've implemented session timeouts on the server end to terminate idle sessions after a configurable idle time, and to shut down the sockets cleanly.Thanks for your help,Rich.
richJTSa at 2007-7-8 23:06:04 > top of Java-index,Archived Forums,Socket Programming...