Detecting Client Outages in Web Services

I am using Apache CXF Web Services Stack. When the client finishes work or disconnects from the server before the operation is completed, the server continues the operation until it is completed. I would like the server to detect when the client disconnects and processes this accordingly.

Is there a way to detect when a client disconnects using Apache CXF? How to use other Java web service stacks?

+6
java web-services cxf webservice-client
source share
1 answer

I am not familiar with Apache CXF , but the following should apply to any Java Servlet base.

To determine if the user is disabled (stop button, closed browser, etc.), the server should try to send the packet. If the TCP / IP connection has been closed, an IOException will be IOException .

Theoretically, a Java application could send a space character at different points during processing. IOException will signal that the client has left, and processing may be interrupted.

However, there may be several problems with this method:

  • Sending characters during processing will cause the response to be "fixed", so it may not be possible to set HTTP headers, cookies, etc. based on the result of lengthy server processing.

  • If the output stream is buffered, space characters will not be sent immediately, thereby not performing an adequate test. It is possible to use flush() as a workaround.

  • It may be difficult to implement this method for a given structure or viewing technology (JSP, etc.). For example, the page rendering code will not be able to send the content type after the response has been committed.

+2
source share