Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8597

CXF JAXRS client not closing HTTP connections

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.4.3, 3.4.4
    • 3.5.0, 3.4.5
    • JAX-RS
    • None
    • CXF 3.4.3/3.4.4

      OpenJDK 11.11

    • Unknown

    Description

      After upgrading from cxf-3.3.4 to 3.4.3 we noticed large numbers of HTTP connections remaining in CLOSE_WAIT state, originating from JAXRS proxy clients - unfortunately in production first.
      The open sockets lead to a total blockage of the system as file handles eventually are exhausted and no further addtional connections can be opened. At this point we see tens of thousands connections in CLOSE_WAIT.

      During our investigation we spotted a substantial refactoring in https://github.com/apache/cxf/blob/75fb6bb56d82f72771a9ee6ecab5d36168303f51/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java#L424 which seems to cause the issue (parameter "closeAfterRead" being always false).

      Please refer to the attached reproducer project which demonstrates the issue - the underlying HttpUrlConnection never being closed in cxf-3.4.3/3.4.4. By changing the build.gradle.kts of the reproducer to use cxf-3.3.4 the included test case is working. 

       

      If possible please advise a workaround. Our initial attempts to get "behind" ResponseImpl#doReadEntity via the client interceptor chain were unsuccessful.

      For the time being production operators are forcibly removing CLOSE_WAIT connections by OS means ("ss --tcp state CLOSE-WAIT '( dport = <api-gateway-port> )' --kill")

       

       

      Attachments

        1. cxf-jaxrs-connection-close.zip
          60 kB
          Lars Ködderitzsch

        Issue Links

          Activity

            People

              reta Andriy Redko
              lkoe Lars Ködderitzsch
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: