我找到了问题的根本原因。
由于某种原因,连接变为无效,并且池不知道该连接。
在这种情况下,NoHttpResponseException
将引发且请求仅失败。我认为此类问题应在HTTP客户端池层中解决,并且对我的代码是透明的,但事实并非如此。
要解决此问题HttpRequestRetryHandler
,HTTP客户端应被覆盖:
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
...
DefaultHttpClient httpClient = new DefaultHttpClient(cm, params);
httpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int executionCount,
HttpContext context) {
if (executionCount > 3) {
LOGGER.warn("Maximum tries reached for client http pool ");
return false;
}
if (exception instanceof org.apache.http.NoHttpResponseException) {
LOGGER.warn("No response from server on " + executionCount + " call");
return true;
}
return false;
}
});