Java.io.IOException: Broken pipe crashing embedded tomcat 8 application

I am aware of why the following exception is thrown on the server side (client disconnects from server without reading data). However, when this happens, the server becomes extremely slow and unresponsive. I am looking at potential solutions to keep the server resilient to a bad client.

java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_45]
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_45]
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_45]
    at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_45]
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_45]
    at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:127) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:173) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:139) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:197) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer.java:41) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer.java:320) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:84) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.coyote.Response.doWrite(Response.java:503) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:388) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]
    ... 103 common frames omitted
Wrapped by: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:393) ~[tomcat-embed-core-8.0.20.jar!/:8.0.20]

      

+3


source to share


1 answer


I faced a similar situation where every boot through the controller was throwing a Broken Pipe exception, later I found that the root cause of the problem is duplicate spring context boot in tomcat container. This can be verified by looking at the logs for two entries of the same controller method. I resolved this by moving the mvc-dispatcher servlet load exactly once.



+1


source







All Articles