Apache Httpclient Connection not Released

只愿长相守 提交于 2020-04-16 16:01:03

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!