我很熟悉为什么在服务器端引发以下异常(客户端在没有读取数据的情况下断开与服务器的连接)。但是,当发生这种情况时,服务器变得非常缓慢且无响应。我正在寻找可能的解决方案,以便服务器能够适应不良行为客户端。
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]
答案 0 :(得分:1)
我遇到过类似的情况,每次通过控制器下载都会抛出Broken Pipe异常,后来我发现问题的根本原因是在tomcat容器中重复加载spring context。可以通过扫描日志查看同一控制器方法的两个条目来检查这一点。我通过移动加载mvc-dispatcher servlet一次就解决了这个问题。