We're writing an application that processes requests using both a normal
servlet and a CometProcessor. The normal servlet handles user
authentication and logout (among other things). Once the user has been
authenticated, the client makes a Comet request, which is open until the
server has something to push to the client. When the user decides to log
out, we need to stop processing Comet events for that client. I've run
into two issues:
(1) If the client terminates abnormally, a Comet END event is never
generated. Network traces show a RST being sent by the client on the
socket; however, we never get an END (or ERROR) event on the server.
I've seen this with both the NIO and Apr connectors, on Windows.
(Haven't tried other platforms.) If the client resets the socket,
shouldn't the CometProcessor get some sort of event? If the client is
going to shut down normally, is there a good way to explicitly close the
Comet connection?
(2) I enabled the CometConnectionManagerValve in context.xml, hoping I
would at least get an END event when the session goes away. Instead, I
get an IllegalStateException:
Mar 10, 2008 2:05:41 PM org.apache.catalina.connector.CoyoteAdapter event
SEVERE: An exception or error occurred in the container during the
request processing
java.lang.IllegalStateException: Cannot create a session after the
response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2301)
at org.apache.catalina.connector.Request.getSession(Request.java:2075)
at
org.apache.catalina.valves.CometConnectionManagerValve.event(CometConnectionManagerValve.java:311)
at
org.apache.catalina.core.StandardHostValve.event(StandardHostValve.java:179)
at org.apache.catalina.valves.ValveBase.event(ValveBase.java:200)
at
org.apache.catalina.core.StandardEngineValve.event(StandardEngineValve.java:128)
at
org.apache.catalina.connector.CoyoteAdapter.event(CoyoteAdapter.java:198)
at
org.apache.coyote.http11.Http11NioProcessor.event(Http11NioProcessor.java:749)
at
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.event(Http11NioProtocol.java:653)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2080)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Presumably my servlet handles the "logout" request, and after sending a
response to the client, calls invalidate() on the HttpSession.
Subsequently, CometConnectionManagerValue.event() calls
request.getSession(true), resulting in the IllegalStateException.
I'd be happy to file bugs for these issues with additional supporting
information, but I wanted to see if these were known issues or if I
might be doing something wrong.
Thanks,
--Daniel Rabe