Java socket not throwing exceptions on a dead socket??
Joined: Apr 14, 2009
We have a simple client server architecture between our mobile device and our server both written in Java. An extremely simple ServerSocket and Socket implementation. However one problem is that when the client terminates abruptly (without closing the socket properly) the server does not know that it is disconnected. Furthermore, the server can continue to write to this socket without getting any exceptions. Why?
According to documentation Java sockets should throw exceptions if you try to write to a socket that is not reachable on the other end!
What is the route from your server to your mobile device? Is there some intermediate proxy that could be staying alive even though the complete route is broken?
You may have to add in a "heartbeat" message that does a round trip from server to client and back to make sure the route is intact.