Sunday, 8 September 2013

Both ends of Java socket hung on flush

Both ends of Java socket hung on flush

We have a set of applications, written in Java, which communicate with
each other by sending short XML messages via sockets. At present, during
development, we are running all the applications on the same workstation.
Our problem is that it is somehow possible, after some tens of thousands
of messages have been exchanged in each direction, for the socket
connections between these programs to hang.
Looking at the problem in the Eclipse debugger, we find that both ends of
the connection are running separate instances of identical code. Both ends
have just successfully written a valid message to a BufferedWriter based
on the Socket, using its write(String) call, and both ends appear to be
blocked waiting on completion of a BufferedWriter flush() call. There is
nothing unusual about the code, and it runs flawlessly for thousands of
messages before hanging. No exceptions are thrown on either end, and the
wait appears to be indefinite. We have observed this problem while running
on both Linux and Windows platforms.
Can anyone suggest what might be going on?

No comments:

Post a Comment