采用httpClient拉取服务端数据,偶尔会出现异常:java.net.SocketException: Software caused connection abort: recv failed

juque 发布于 2018/03/06 13:58
阅读 2K+
收藏 1

用httpClient发送http请求,拉取服务端的数据,不定时会出现下面的异常:
网络异常,堆栈轨迹如下
java.net.SocketException: Software caused connection abort: recv failed
        at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_112]

        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[n
a:1.8.0_112]
        at java.net.SocketInputStream.read(SocketInputStream.java:170) ~[na:1.8.
0_112]
        at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.
0_112]
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInpu
tBufferImpl.java:137) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInpu
tBufferImpl.java:153) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputB
ufferImpl.java:282) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
HttpResponseParser.java:138) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(Default
HttpResponseParser.java:56) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessagePa
rser.java:259) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHead
er(DefaultBHttpClientConnection.java:163) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy
.java:165) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRe
questExecutor.java:273) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecu
tor.java:125) ~[httpcore-4.4.6.jar:4.4.6]
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.
java:272) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java
:185) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~
[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java
:111) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttp
Client.java:185) ~[httpclient-4.5.3.jar:4.5.3]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttp
Client.java:83) ~[httpclient-4.5.3.jar:4.5.3]
        at cn.titantec.powerweb.util.HttpClientUtil.sendPostRequest(HttpClientUt
il.java:254) [HttpClientUtil.class:na]
        at cn.titantec.powerweb.util.HttpClientUtil.sendPostRequest(HttpClientUt
il.java:217) [HttpClientUtil.class:na]

客户端采用httpClient拉取数据;
服务端是采用spring+spring-mvc架构。哪位大神能解答下?

------------------------------------------------------------------------------------------

运行环境:tomcat7,jdk1.8

httpClient版本号:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>

加载中
0
Lee__K
Lee__K

同问, 请问解决了吗, 有没可能是 服务端的问题? 

0
osc_27048157
osc_27048157

我用socket写了个客户端和服务端聊天的程序,客户端和服务端能正常的互发消息,然后我先关闭客户端,但不关闭服务端,我又重新打开客户端,连是连上了,但是一发消息,服务端就报这个错,等于说是第一次服务端给客户端分配的那个端口我是未关闭的,那个端口的输入输出流我也没关闭,第二次又连这个端口,是不是会冲突

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部