java.net.SocketException有什么区别:Connection reset和java.net.SocketException:Broken Pipe?

时间:2011-01-10 22:24:06

标签: java sockets

java.net.SocketException: Connection resetjava.net.SocketException: Broken Pipe之间的区别是什么?

我想弄清楚这两个例外的原因是什么。我们的服务器上出现以下错误,基本上是基于SOAP的Web服务。当我尝试中止客户端调用我看到的异常是Broken pipe ...

以下是我们的堆栈跟踪,感谢任何帮助!

2011-01-10 00:44:33,828 96893947 INFO  [STDOUT] (http-0.0.0.0-8180-Processor25:) ERROR:  ''
2011-01-10 00:44:33,829 96893948 INFO  [STDOUT] (http-0.0.0.0-8180-Processor25:) Jan 10, 2011 12:44:33 AM com.sun.xml.rpc.server.http.JAXRPCS
ervletDelegate doGetDefault
SEVERE: JAXRPCSERVLET34: transformation failed : ClientAbortException:  java.net.SocketException: Connection reset
JAXRPCSERVLET34: transformation failed : ClientAbortException:  java.net.SocketException: Connection reset
        at com.sun.xml.rpc.server.http.WSDLPublisher.handle(WSDLPublisher.java:109)
        at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doGetDefault(JAXRPCServletDelegate.java:185)
        at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doGet(JAXRPCServletDelegate.java:153)
        at com.sun.xml.rpc.server.http.JAXRPCServlet.doGet(JAXRPCServlet.java:111)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
--
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
2011-01-10 00:44:33,829 96893948 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/soa].[UserService]] (http-0.0.0.0-81
80-Processor25:) Servlet.service() for servlet UserService threw exception
javax.servlet.ServletException: JAXRPCSERVLET34: transformation failed : ClientAbortException:  java.net.SocketException: Connection reset
        at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doGetDefault(JAXRPCServletDelegate.java:347)
        at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doGet(JAXRPCServletDelegate.java:153)
        at com.sun.xml.rpc.server.http.JAXRPCServlet.doGet(JAXRPCServlet.java:111)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

4 个答案:

答案 0 :(得分:4)

这些是TCP协议级别的错误条件。它们都基本上意味着另一方关闭了TCP连接。不同之处在于发生的沟通阶段。

答案 1 :(得分:4)

读取或写入时可能会发生“连接重置”。 '断管'只能在写字时出现。两者都是由写入已经被另一端关闭的连接引起的,或者是由于其他原因而被重置的。

答案 2 :(得分:4)

当对等方关闭连接时(即在另一方持有连接的应用程序),会出现Connection resetBroken pipe

在写作(见java.net.SocketOutputStream)或阅读(见java.net.SocketInputStream)时可能会发生{p> Connection reset

Broken pipe出现在java.net.SocketException

的Native方法中
java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)

因此,Broken pipe发生在较低的沟通水平,正如Michael Borgwardt所建议的那样。

在大多数情况下,我在向客户端浏览器发送大型PDF时看到此错误,并且用户在获取整个文档之前杀死了浏览器(在这种情况下,我只是忽略了错误,因为这是用户选择关闭它浏览器,没有什么可以纠正的)。但也可能是其他原因(例如EJP suggests more reason related to data communication protocols)。

答案 3 :(得分:0)

两者似乎都指向类似的情况 - 远程套接字不再可用于写入。

最近通过我的实验,我发现当我的服务器在Unix环境中时,就会发生Broken管道,我终止了客户端。

015-06-26 10:53:51,028-0400 [ERROR][WS-ASync] (Handler.java:1168) Exception while writing ClientAbortException:  java.net.SocketException: Broken pipe
ClientAbortException:  java.net.SocketException: Broken pipe
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:413)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:371)
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:438)

然而,当服务器在Windows上运行时,我看到连接重置异常

2015-06-26 09:11:31,491 ERROR [WS-ASync] (Handler.java:1168) - Exception while writing ClientAbortException:  java.net.SocketException: Connection reset by peer: socket write error
ClientAbortException:  java.net.SocketException: Connection reset by peer: socket write error
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:388)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:462)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366)
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:413)
        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:366)