Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-718

Getting org.apache.http.ConnectionClosedException after httpcore-nio version upgrade

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 4.4.15
    • None
    • HttpCore NIO
    • None
    • Java version: 11.0.15.1
      OS: macOS Monterey (Version 12.12.1) 

    Description

      We recently migrated to httpcore-nio 4.4.15 and we have been encountering some issues when connecting to an HTTPS Backend that sends chunked responses. The backend behaves in such a manner that when it sends the response, it immediately closes the connection after completion. 

      We have attached a reproducer to this ticket and the behavior is as below.

      When httpcore-nio 4.4.15 is used, the client gets the error:

      org.apache.http.ConnectionClosedException: Connection closed unexpectedly

      But, when httpcore-nio 4.4.5 is used, the client receives the complete response, which was sent from the backend.

      We further checked on the following versions and the observations are as below. 

      • httpcore-nio 4.4.10 - receives the complete response
      • httpcore-nio 4.4.11 - receives org.apache.http.ConnectionClosedException

      In order to replicate the issue, we did a few changes to the consumeContent(final ContentDecoder decoder) method inside the SimpleInputBuffer class. You may find the changes in the attached source code.

      In order to test the behavior, please run the Main class: “TestChunkedBackend”.

      Tested environment:

      • Java version: 11.0.15.1
      • OS: macOS Monterey (Version 12.12.1) 

      A similar issue can be found here https://issues.apache.org/jira/browse/HTTPCORE-706

      Thanks & Regards,
      Sajinie

       

      Attachments

        1. HttpNIOTestClient_new.zip
          167 kB
          Sajinie Kavindya
        2. HttpNIOTestClient.zip
          186 kB
          Sajinie Kavindya
        3. HttpNIOTestClient-1.zip
          174 kB
          Sajinie Kavindya

        Activity

          People

            Unassigned Unassigned
            sajiniekavindya Sajinie Kavindya
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: