How to fix java.net.SocketException: Broken pipe?(如何修复 java.net.SocketException:损坏的管道?)
问题描述
我正在使用 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:损坏的管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何修复 java.net.SocketException:损坏的管道?
基础教程推荐
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01