How to solve org.apache.http.NoHttpResponseException

前端 未结 2 1643
名媛妹妹
名媛妹妹 2021-02-09 23:24

I\'m using apache httpclient 4.4 to do https requests, and I can constantly to see org.apache.http.NoHttpResponseException.

Here\'s my code to create the h

2条回答
  •  感情败类
    2021-02-10 00:03

    Finally figured it out on my own. If the previous response gives header, "connections=close", next request always gets this exception. So, when seeing this header, put 2 more lines

    conManager.closeExpiredConnections();
    conManager.closeIdleConnections(0, TimeUnit.SECONDS);
    

    to let connection manager close the connection so that the connection won't be used by the next request.

提交回复
热议问题