本文介绍了如何修复 java.net.SocketException: Broken pipe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 apache commons http 客户端通过 post 方法调用 url 来发布参数,并且它很少抛出以下错误.
I am using apache commons http client to call url using post method to post the parameters and it is throwing the below error rarely.
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
at java.io.FilterOutputStream.write(FilterOutputStream.java:80)
at org.apache.commons.httpclient.methods.ByteArrayRequestEntity.writeRequest(ByteArrayRequestEntity.java:90)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
有人可以建议导致此异常的原因以及如何调试它吗?
Can someone suggest what is causing this Exception and how to debug it?
推荐答案
这是由于:
- 最常见的是,在另一端已经关闭连接时写入连接;
- 通常情况下,对等方关闭连接而不读取其端已经挂起的所有数据.
因此,在这两种情况下,您的应用程序协议定义或实施都很糟糕.
So in both cases you have a poorly defined or implemented application protocol.
还有第三个原因,我不会在这里记录,但它涉及对等方采取故意的行动来重置而不是正确关闭连接.
There is a third reason which I will not document here but which involves the peer taking deliberate action to reset rather than properly close the connection.
这篇关于如何修复 java.net.SocketException: Broken pipe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!