Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1583

Add option to create a connection eviction thread for a non-shared connection manager

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.3.5
    • 4.4 Final
    • None
    • None

    Description

      In the tutorial:
      http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html, section 2.5 Connection eviction policy - you explain how to clean-up connections. Although I can argue against the design as without this if server closes connections, my client gets many sockets stuck on CLOSE_WAIT - adding this thread solves the CLOSE_WAIT issue.

      However, I don't understand why you don't do this yourself if keep-alive is set. I would expect the library to support such a thread. In the meanwhile, it seems that if I use the default connection manager, I can't use non-deprecated code to call :

      connMgr.closeExpiredConnections();
      and
      connMgr.closeIdleConnections(30, TimeUnit.SECONDS);

      This is because the only exposed API to get the default pooling connection manager is by calling:

      httpClient.getConnectionManager(), which is deprecated. Javadoc suggests to go to the builder (which I do use but not for creating connection pool as the default is good enough for me) which is useless.

      So - how should one acquire a reference to the connection manager?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yairogen yair ogen
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: