Apache HttpClient: How to auto close connections by server's keep-alive time?

前端 未结 2 1527
没有蜡笔的小新
没有蜡笔的小新 2021-02-09 16:40

Apache HttpClient 4.3b2, HttpCore 4.3.

I use PoolingHttpClientConnectionManager to manage 5 connections concurrently:

PoolingHttpClientConne         


        
2条回答
  •  囚心锁ツ
    2021-02-09 17:09

    In PoolingHttpClientConnectionManager class there is a method setValidateAfterInactivity that sets period of connection inactivity in milliseconds. If this period has been exceeded connection pool revalidates connection before passing it to HttpClient. This method is available since v.4.4. In prior versions RequestConfig.Builder.setStaleConnectionCheckEnabled method could have been used.

提交回复
热议问题