I am trying to hit a server using http client using PoolingClientConnectionManager
setting max connections for individual hosts
//Code that ini
Recently faced similar while using HttpClient 5
.
On enabling the HttpClient
logs and found that the issue was due to stale connections.
Adding the below helped to solve the issue, it detects and validates the connections that have become stale while kept inactive in the pool before reuse.
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setValidateAfterInactivity(timeinmilliseconds);
Probably, it is a bug in the HttpClient.
If you are using the HttpClient 4.4, please try to upgrade to 4.4.1.
If you want for more information, please look at this link.
If you can't upgrade, the following links might be helpful.
http://www.nuxeo.com/blog/using-httpclient-properly-avoid-closewait-tcp-connections/
Good luck!