org.apache.http.NoHttpResponseException

org.apache.http.NoHttpResponseException

异常: org.apache.http.NoHttpResponseException: The target server failed to respond 
  at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141) 
  at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) 
  at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) 
  at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) 
  at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) 
  at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) 
  at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) 
  at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) 
  at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) 
  at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) 
  at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) 
  at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) 
  at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) 
  at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) 

主要原因server端连接已经关闭, client没有接收到关闭的通知

httpClient 4.4中setStaleConnectionCheckEnabled默认变成false了, 之前的版本默认是true 换jar版本要详细测试
  • 解决方法:
    • client请求加重试
    • client起线程主动检查
posted @ 2019-07-09 19:51  funny_coding  阅读(6804)  评论(0编辑  收藏  举报
build beautiful things, share happiness