tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Chilton" <jmchil...@gmail.com>
Subject Closing a CometEvent in Tomcat 6.0.16
Date Wed, 16 Jul 2008 19:08:31 GMT
Hello All,

So I have a piece of code that writes something out to the
ServletOutputStream associated with a Comet Event, flushes the stream,
and then calls cometEvent.close() in response to an END event. This
whole process in synchronized. Today while attempting to flush the
stream, an exception was thrown...

Here is a log of the exception:

ClientAbortException:  java.io.IOException: Connection reset by peer
       at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:319)
       at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288)
       at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:98)
       at rocket.remoting.server.CometConnection.flush(CometConnection.java:137)
       at rocket.remoting.server.CometConnection.close(CometConnection.java:115)
       at edu.umn.msi.tropix.webgui.server.comet.CometManagerImpl.close(CometManagerImpl.java:271)
       at edu.umn.msi.tropix.webgui.server.comet.CometManagerImpl.close(CometManagerImpl.java:291)
       at edu.umn.msi.tropix.webgui.server.comet.TomcatServlet.event(TomcatServlet.java:43)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilterEvent(ApplicationFilterChain.java:470)
       at org.apache.catalina.core.ApplicationFilterChain.doFilterEvent(ApplicationFilterChain.java:363)
       at org.apache.catalina.core.StandardWrapperValve.event(StandardWrapperValve.java:422)
       at org.apache.catalina.core.StandardContextValve.event(StandardContextValve.java:252)
       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:650)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
       at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.IOException: Connection reset by peer
       at sun.nio.ch.FileDispatcher.write0(Native Method)
       at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)
       at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:104)
       at sun.nio.ch.IOUtil.write(IOUtil.java:60)
       at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:302)
       at org.apache.tomcat.util.net.SecureNioChannel.flush(SecureNioChannel.java:124)
       at org.apache.tomcat.util.net.SecureNioChannel.write(SecureNioChannel.java:431)
       at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:92)
       at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:156)
       at org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:440)
       at org.apache.coyote.http11.InternalNioOutputBuffer.flushBuffer(InternalNioOutputBuffer.java:770)
       at org.apache.coyote.http11.InternalNioOutputBuffer.flush(InternalNioOutputBuffer.java:300)
       at org.apache.coyote.http11.Http11NioProcessor.action(Http11NioProcessor.java:1051)
       at org.apache.coyote.Response.action(Response.java:183)
       at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
       ... 21 more

When my code then attempted to close the CometEvent, the thread hung.
The stack trace of the stuck thread looks like this:

org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer.java:46)
org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer.java:803)
org.apache.coyote.http11.filters.ChunkedOutputFilter.end(ChunkedOutputFilter.java:164)
org.apache.coyote.http11.InternalNioOutputBuffer.endRequest(InternalNioOutputBuffer.java:390)
org.apache.coyote.http11.Http11NioProcessor.action(Http11NioProcessor.java:1079)
org.apache.coyote.Response.action(Response.java:183)
org.apache.coyote.Response.finish(Response.java:305)
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:276)
org.apache.catalina.connector.Response.finishResponse(Response.java:492)
org.apache.catalina.connector.CometEventImpl.close(CometEventImpl.java:96)
edu.umn.msi.tropix.webgui.server.comet.CometManagerImpl.close(CometManagerImpl.java:279)
edu.umn.msi.tropix.webgui.server.comet.CometManagerImpl.close(CometManagerImpl.java:291)
edu.umn.msi.tropix.webgui.server.comet.TomcatServlet.event(TomcatServlet.java:43)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilterEvent(ApplicationFilterChain.java:470)
org.apache.catalina.core.ApplicationFilterChain.doFilterEvent(ApplicationFilterChain.java:363)
org.apache.catalina.core.StandardWrapperValve.event(StandardWrapperValve.java:422)
org.apache.catalina.core.StandardContextValve.event(StandardContextValve.java:252)
org.apache.catalina.core.StandardHostValve.event(StandardHostValve.java:179)
org.apache.catalina.valves.ValveBase.event(ValveBase.java:200)
org.apache.catalina.core.StandardEngineValve.event(StandardEngineValve.java:128)
org.apache.catalina.connector.CoyoteAdapter.event(CoyoteAdapter.java:198)
org.apache.coyote.http11.Http11NioProcessor.event(Http11NioProcessor.java:749)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.event(Http11NioProtocol.java:653)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2080)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
java.lang.Thread.run(Thread.java:595)

I guess I have several questions, the most practical is - will not
attempting to close the comet event after an exception while flushing
prevent this thread for hanging or will the underlying problem still
prevent close from halting.

My second question is, is this behavior to be expected, is it a bug,
or am I doing something wrong?

Would this patch
http://people.apache.org/~fhanik/patches/comet-async-close.patch "fix"
this?

Finally, I previously had a similar problem with threads hanging when
a library I make use of was closing the ServletOutputStream associated
with a CometEvent and then my code would attempt to close the
CometEvent afterward. This would also randomly hang. Are these
problems related?

Thanks for any help.

-John Chilton

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message