tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Cazan <>
Subject How to handle client disconnection in 'no timeout' async servlets?
Date Thu, 09 Jun 2011 12:22:38 GMT
I am using Tomcat 7.0.14. I used to have a servlet implementing CometProcessor to process
asynchronous streams, with timeout set very high (Integer.MAX_VALUE), and all worked fine.
When I close the browser, the servlet is notified immediately about that (CometEvent.EventType.END)
and I am happy to do the cleanup.
No, I have created an async servlet 3.0, and all works as I expected, except for notification
when the browser is closed. I used request.startAsync(), I added AsyncListener, and none of
the events get fired when the browser is suddenly closed. Since I set the timeout to a large
value (Long.MAX_VALUE), AsyncListener.onTimeout will never get called.
As far as I understand, onComplete will get called only when I call AsyncContext.complete(),
and I do not know when to call it. I tried to write on response.getWriter(), expecting to
see an exception, but no exception was thrown after a couple of writes.
How can I handle this situation using servlet api 3.0, when the user closes the browser or
hits the stop button? I need to do the cleanup for that client.Meanwhile, I reverted the source
code to CometProcessor.
Thanks a lot,Paul
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message