Help needed: Java Socket and close detection

Langer, Christoph christoph.langer at sap.com
Wed Jul 13 15:29:07 UTC 2016


Hi folks,

I have a question to the experts - regarding an issue that was reported to me by a customer.

In the customer scenario they are running a Servlet engine and the Servlet is constantly sending data to a browser client. When the browser client is closed, the server does not get a notification of the other end having been terminated and is constantly sending out data and blocking an application thread. I'm under the assumption that the server should get an RST packet from the network upon writing/flushing data to the OutputStream as soon as the client is gone and hence an Exception should pop up but this isn't happening.

There is a load balancer and maybe other network infrastructure involved in between the Servlet JVM and the browser client. We did some TCPDUMP tracing at the load balancer and we could not see an RST packet coming in from the client side. But when I'm running the scenario without all this network infrastructure involved, e.g. between servers and clients in the same network, I would always observe an RST packet once I close the browser. A FIN packet is received, too, but this does not lead to an Exception and to all my knowledge this can't be detected, not from the java Socket API and even less from the Servlet API which is just dealing with Streams.

So my question to the experts is most of all: Would you agree that an RST packet should be generated in the network and received by the server? Or is it a normal behavior that servers must deal with not receiving RSTs and hence needing to wait for a timeout until e.g. the load balancer generates an RST? Also, is there any way to detect a FIN in the JVM and react on it?

Thanks in advance and best regards
Christoph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20160713/44715080/attachment.html>


More information about the nio-dev mailing list