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

CLOSE_WAIT issue in HttpClient

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 4.5.5
    • None
    • HttpClient (async)
    • None

    Description

      We are facing CLOSE_WAIT issue in our production system on heavy load. We are using Apache's httpClient 4.5.5 and httpcore 4.4.9 in our code. Sometime the server sends half of the data; sometime server sends no data and close the connection at their end. Now, httpclient puts the socket connection to CLOSE_WAIT indefinitely. 

      We tried the following but nothing helped us.

         Later, we found the method "setValidateAfterInactivity". Its description says "This check helps detect connections that have become stale (half-closed) while kept inactive in the pool". So we thought it will help us to detect and close the socket which are in "CLOSE_WAIT" state. But it did not help us.

      Problem here, The HTTP client puts the socket into "CLOSE_WAIT" state and waiting for the signal from server to close the socket. But the server closed the connection already.  Please suggest us how to handle/resolve the issue?

       

      Scala Code Snippet

      private val clientConnectionManager =

      { val clientConnectionManager = new PoolingHttpClientConnectionManager(1, java.util.concurrent.TimeUnit.MINUTES); clientConnectionManager.setMaxTotal(cfg.connectionPoolSize) clientConnectionManager.setDefaultMaxPerRoute(cfg.connectionPoolSize) clientConnectionManager.setValidateAfterInactivity(30000); clientConnectionManager }

      val monitorThread = new IdleConnectionMonitorThread(clientConnectionManager);
      monitorThread.start();

       

       

       

      Attachments

        1. frt-acs03-netstat.log
          18 kB
          Santhosh Sheshasayanan
        2. Capture.PNG
          177 kB
          Santhosh Sheshasayanan
        3. IdleConnectionMonitorThread.java
          1 kB
          Santhosh Sheshasayanan
        4. Capture-0.PNG
          11 kB
          Santhosh Sheshasayanan
        5. Capture-1.PNG
          85 kB
          Santhosh Sheshasayanan
        6. close_wait.log
          9.42 MB
          Santhosh Sheshasayanan
        7. image-2018-05-01-19-34-15-096.png
          48 kB
          Santhosh Sheshasayanan

        Activity

          People

            Unassigned Unassigned
            ssanthosh29 Santhosh Sheshasayanan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: