问题
I am using spring rest template to send REST request with apache http client 4.2.1 intergrated.
As we need send request to multiple server, added PoolingClientConnectionManager to manager the connections.
Set the max per route to 5 connectionManager.setDefaultMaxPerRoute(5)
While after the system running for few days, we found that the connection reached the maxmium per route settings.
Printed log as below total kept alive: 0; route allocated: 5 of 5; total allocated: 5 of 100
Seems the connection is not released by some reason. But when i debug, i found every time after request is finished, the connection will be released even there's exception happens.
Is there any other potential root cause of this connection cannot be released?
回答1:
It's because in some case, the server hold the request, we need add timeout for http client
来源:https://stackoverflow.com/questions/28635232/apache-httpclient-connection-not-released