Broken pipe错误后Tomcat servlet映射错误

Posted

技术标签:

【中文标题】Broken pipe错误后Tomcat servlet映射错误【英文标题】:Tomcat servlet mapping error after Broken pipe error 【发布时间】:2012-07-18 07:04:16 【问题描述】:

我们已经在 Tomcat 版本 7.0.23 中实现了 Servlet 3.0 AsyncContext。

它正在RHEL 6.1 using OpenJDK version 1.6.0_24,64-bit 服务器中运行

该应用在大部分情况下都运行良好。 当网络出现一些干扰时,来自服务器的更新无法到达客户端,因为存在“ClientAbortException: java.net.SocketException: Broken pipe”异常。被捕获并忽略。

这发生在一行中,

asyncContext.getResponse().getWriter().println(updateStr);

在这个 Tomcat 发疯并将 URL 路由到意外的 servlet 之后。 例如,使用 /query 映射到名为 SessionManager 的 servlet,URL mysite.com/index.html 被路由到 SessionManager servlet。 只有重启tomcat才能解决问题。

关于为什么会发生这种情况以及如何解决这个问题的任何指示?

只是为了添加更多数据,以下是异常的堆栈跟踪。

ClientAbortException:  java.net.SocketException: Broken pipe
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:346)
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:306)
    at org.apache.catalina.connector.Response.flushBuffer(Response.java:568)
    at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:307)
    at com.management.TestHandler$TestInfo.statusUpdate(TestHandler.java:638)
    at com.chakra.ipbtt.TestObject.publish(TestObject.java:1626)
    at com.chakra.ipbtt.TestObject.handlePublish(TestObject.java:1421)
    at com.chakra.ipbtt.TestObject.executeCommand(TestObject.java:1371)
    at com.chakra.ipbtt.TestObject.executeCommand(TestObject.java:1388)
    at com.chakra.ipbtt.TestObject.executeCommand(TestObject.java:1388)
    at com.chakra.ipbtt.TestObject.executeCommand(TestObject.java:1388)
    at com.chakra.ipbtt.TestObject.executeCommand(TestObject.java:1388)
    at com.chakra.ipbtt.TestObject.executeCommand(TestObject.java:1388)
    at com.chakra.ipbtt.TestObject.executeTest(TestObject.java:1791)
    at com.management.TestHandler.executeTest(TestHandler.java:420)
    at com.management.TestHandler.handleNewTest(TestHandler.java:222)
    at com.management.TestMgr.processRequest(TestMgr.java:71)
    at com.management.TestMgr.doPost(TestMgr.java:105)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:690)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:477)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at com.management.SessionMgr.processRequest(SessionMgr.java:131)
    at com.management.SessionMgr.doPost(SessionMgr.java:164)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.management.SessionsFilter.doFilter(SessionsFilter.java:127)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)

Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:462)
    at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119)
    at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:789)
    at org.apache.coyote.Response.action(Response.java:174)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:341)
    ... 48 more`

【问题讨论】:

您好,您找到解决方法或原因了吗? 【参考方案1】:

这听起来像是 Tomcat 的一个错误。

首先,我会尝试更新到 Apache Tomcat 7.0.64

其次,我会尝试更新到 Java 6u45

【讨论】:

【参考方案2】:

我们在服务器端遇到了类似的问题。事实证明,我们作为响应发送的数据集在过滤级别被阻止,因为数据非常庞大,并且在这个级别爆炸了。

@Component
public class TrackingFilter implements TraceRepository, Filter 
/**
* Few other business relarted code
*
byte[] bytes = pw.toByteArray();
response.getOutputStream().write(bytes);

【讨论】:

以上是关于Broken pipe错误后Tomcat servlet映射错误的主要内容,如果未能解决你的问题,请参考以下文章

Broken pipe错误

Broken pipe错误

linux 下 tomcat 运行报错 Broken pipe

Tomcat JDBC Conencton Pool + MySQL 会出现“Broken pipe”问题,即使有连接验证

套接字:send() 函数返回“Broken Pipe”错误

Android 错误:写入失败:EPIPE (Broken pipe)