org.apache.catalina.connector.ClientAbortException: null

Java.net JIRA | ricb | 2 years ago
  1. 0

    Jersey Server-Sent Events - write to broken connection does not throw exception

    Stack Overflow | 2 years ago | ricb
    org.apache.catalina.connector.ClientAbortException: null
  2. 0

    We are using Server-Sent Events to allow our client application to listen to events raised by our Jersey server. This works great. We have a requirement for our server to have an accurate list of currently-connected SSE callers (instances of our client application). To this end, our server sends a tiny message to each client (via eventOutput.write) once every five seconds. If our client is shut down while SSE-connected, or if the remote computer is powered off while SSE-connected, our server's eventOutput.write call correctly throws the ClientAbortException/SocketException exception shown below. That's perfect: we catch the exception, and mark that client as no longer connected. The problem: there are two cases where calling eventOutput.write to a no-longer-connected computer does NOT throw an exception: 1) if the Ethernet cable of the remote computer is disconnected while the client is SSE-connected, and 2) if the network adapter in the remote computer is turned off (e.g., by an administrator) while the client is SSE-connected. In these two cases, eventOutput.write does not throw an exception. We can call eventOutput.write to the remote computer every five seconds for hours and no exception is thrown. This makes it impossible to detect that the remote computer is no longer connected. To sum up, there are four cases: 1) Client software is shut down: eventOutput.write() correctly throws an exception. 2) Computer running client software is powered down: eventOutput.write() correctly throws an exception. 3) Etherhet cable is disconnected from computer running client software: eventOutput.write does not detect broken connection. 4) Network adapter on computer running client software is turned off: eventOutput.write does not detect broken connection. Here is the (good/useful) exception we get in cases where eventOutput.write DOES throw the exception we want: {code} org.apache.catalina.connector.ClientAbortException: null at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:371) ~[catalina.jar:7.0.53] at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:333) ~[catalina.jar:7.0.53] at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101) ~[catalina.jar:7.0.53] at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.flush(ResponseWriter.java:303) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.message.internal.CommittingOutputStream.flush(CommittingOutputStream.java:292) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:240) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:190) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.internal.Errors.process(Errors.java:242) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:347) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput.flushQueue(ChunkedOutput.java:190) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput.write(ChunkedOutput.java:180) ~[jaxrs-ri-2.13.jar:2.13.] at com.appserver.webservice.AgentSsePollingManager$ConnectionChecker.run(AgentSsePollingManager.java:174) ~[AgentSsePollingManager$ConnectionChecker.class:na] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_71] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [na:1.7.0_71] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_71] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.7.0_71] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71] Caused by: java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.7.0_71] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:1.7.0_71] at java.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[na:1.7.0_71] at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215) ~[tomcat-coyote.jar:7.0.53] at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) ~[tomcat-coyote.jar:7.0.53] at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119) ~[tomcat-coyote.jar:7.0.53] at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:799) ~[tomcat-coyote.jar:7.0.53] at org.apache.coyote.Response.action(Response.java:174) ~[tomcat-coyote.jar:7.0.53] at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:366) ~[catalina.jar:7.0.53] ... 19 common frames omitted {code}

    Java.net JIRA | 2 years ago | ricb
    org.apache.catalina.connector.ClientAbortException: null
  3. 0

    We are using Server-Sent Events to allow our client application to listen to events raised by our Jersey server. This works great. We have a requirement for our server to have an accurate list of currently-connected SSE callers (instances of our client application). To this end, our server sends a tiny message to each client (via eventOutput.write) once every five seconds. If our client is shut down while SSE-connected, or if the remote computer is powered off while SSE-connected, our server's eventOutput.write call correctly throws the ClientAbortException/SocketException exception shown below. That's perfect: we catch the exception, and mark that client as no longer connected. The problem: there are two cases where calling eventOutput.write to a no-longer-connected computer does NOT throw an exception: 1) if the Ethernet cable of the remote computer is disconnected while the client is SSE-connected, and 2) if the network adapter in the remote computer is turned off (e.g., by an administrator) while the client is SSE-connected. In these two cases, eventOutput.write does not throw an exception. We can call eventOutput.write to the remote computer every five seconds for hours and no exception is thrown. This makes it impossible to detect that the remote computer is no longer connected. To sum up, there are four cases: 1) Client software is shut down: eventOutput.write() correctly throws an exception. 2) Computer running client software is powered down: eventOutput.write() correctly throws an exception. 3) Etherhet cable is disconnected from computer running client software: eventOutput.write does not detect broken connection. 4) Network adapter on computer running client software is turned off: eventOutput.write does not detect broken connection. Here is the (good/useful) exception we get in cases where eventOutput.write DOES throw the exception we want: {code} org.apache.catalina.connector.ClientAbortException: null at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:371) ~[catalina.jar:7.0.53] at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:333) ~[catalina.jar:7.0.53] at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101) ~[catalina.jar:7.0.53] at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.flush(ResponseWriter.java:303) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.message.internal.CommittingOutputStream.flush(CommittingOutputStream.java:292) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:240) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:190) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.internal.Errors.process(Errors.java:242) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:347) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput.flushQueue(ChunkedOutput.java:190) ~[jaxrs-ri-2.13.jar:2.13.] at org.glassfish.jersey.server.ChunkedOutput.write(ChunkedOutput.java:180) ~[jaxrs-ri-2.13.jar:2.13.] at com.appserver.webservice.AgentSsePollingManager$ConnectionChecker.run(AgentSsePollingManager.java:174) ~[AgentSsePollingManager$ConnectionChecker.class:na] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_71] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [na:1.7.0_71] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_71] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.7.0_71] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71] Caused by: java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.7.0_71] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:1.7.0_71] at java.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[na:1.7.0_71] at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215) ~[tomcat-coyote.jar:7.0.53] at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) ~[tomcat-coyote.jar:7.0.53] at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119) ~[tomcat-coyote.jar:7.0.53] at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:799) ~[tomcat-coyote.jar:7.0.53] at org.apache.coyote.Response.action(Response.java:174) ~[tomcat-coyote.jar:7.0.53] at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:366) ~[catalina.jar:7.0.53] ... 19 common frames omitted {code}

    Java.net JIRA | 2 years ago | ricb
    org.apache.catalina.connector.ClientAbortException: null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Atmosphere users mailling list - Handling "Broken Pipe" SocketExceptions nicer

    nabble.com | 1 year ago
    org.apache.catalina.connector.ClientAbortException: null
  6. 0

    setting 'Content-Encoding' to gzip or deflate causes java.net.SocketException: Connection reset

    Stack Overflow | 7 months ago | Kayvan Tehrani
    org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Connection reset

  1. linxiaolong 2 times, last 2 months ago
  2. linxiaolong 1 times, last 4 months ago
  3. Tahir 23 times, last 1 month ago
  4. serious2monkeys 6 times, last 1 month ago
  5. kkandda 2 times, last 6 months ago
5 more registered users
85 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.net.SocketException

    Broken pipe

    at java.net.SocketOutputStream.socketWrite0()
  2. Java RT
    SocketOutputStream.write
    1. java.net.SocketOutputStream.socketWrite0(Native Method)[na:1.7.0_71]
    2. java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)[na:1.7.0_71]
    3. java.net.SocketOutputStream.write(SocketOutputStream.java:159)[na:1.7.0_71]
    3 frames
  3. Grizzly HTTP
    InternalOutputBuffer.realWriteBytes
    1. org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)[tomcat-coyote.jar:7.0.53]
    1 frame
  4. Tomcat Util
    ByteChunk.flushBuffer
    1. org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)[tomcat-coyote.jar:7.0.53]
    1 frame
  5. Grizzly HTTP
    Response.action
    1. org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119)[tomcat-coyote.jar:7.0.53]
    2. org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:799)[tomcat-coyote.jar:7.0.53]
    3. org.apache.coyote.Response.action(Response.java:174)[tomcat-coyote.jar:7.0.53]
    3 frames
  6. Glassfish Core
    CoyoteOutputStream.flush
    1. org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:366)[catalina.jar:7.0.53]
    2. org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:333)[catalina.jar:7.0.53]
    3. org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101)[catalina.jar:7.0.53]
    3 frames
  7. jersey-container-servlet-core
    ResponseWriter$NonCloseableOutputStreamWrapper.flush
    1. org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.flush(ResponseWriter.java:303)[jaxrs-ri-2.13.jar:2.13.]
    1 frame
  8. Jersey Core
    CommittingOutputStream.flush
    1. org.glassfish.jersey.message.internal.CommittingOutputStream.flush(CommittingOutputStream.java:292)[jaxrs-ri-2.13.jar:2.13.]
    1 frame
  9. jersey-core-server
    ChunkedOutput$1.call
    1. org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:240)[jaxrs-ri-2.13.jar:2.13.]
    2. org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:190)[jaxrs-ri-2.13.jar:2.13.]
    2 frames
  10. Jersey Core
    RequestScope.runInScope
    1. org.glassfish.jersey.internal.Errors.process(Errors.java:315)[jaxrs-ri-2.13.jar:2.13.]
    2. org.glassfish.jersey.internal.Errors.process(Errors.java:242)[jaxrs-ri-2.13.jar:2.13.]
    3. org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:347)[jaxrs-ri-2.13.jar:2.13.]
    3 frames
  11. jersey-core-server
    ChunkedOutput.write
    1. org.glassfish.jersey.server.ChunkedOutput.flushQueue(ChunkedOutput.java:190)[jaxrs-ri-2.13.jar:2.13.]
    2. org.glassfish.jersey.server.ChunkedOutput.write(ChunkedOutput.java:180)[jaxrs-ri-2.13.jar:2.13.]
    2 frames
  12. com.appserver.webservice
    AgentSsePollingManager$ConnectionChecker.run
    1. com.appserver.webservice.AgentSsePollingManager$ConnectionChecker.run(AgentSsePollingManager.java:174)[AgentSsePollingManager$ConnectionChecker.class:na]
    1 frame
  13. Java RT
    Thread.run
    1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[na:1.7.0_71]
    2. java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)[na:1.7.0_71]
    3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)[na:1.7.0_71]
    4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[na:1.7.0_71]
    5. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[na:1.7.0_71]
    6. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[na:1.7.0_71]
    7. java.lang.Thread.run(Thread.java:745)[na:1.7.0_71]
    7 frames