jira-importer opened a new issue, #1116: URL: https://github.com/apache/httpcomponents-core/issues/1116
**[Brian B](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=gujunlong)** opened **[HTTPCORE-600](https://issues.apache.org/jira/browse/HTTPCORE-600?redirect=false)** and commented Initially I created this under CXF (CXF-8113), but I think the consensus is it is an NIO issue. The description from that Jira edited to remove CXF-specific changes: When using the Asynchronous Client HTTP Transport to handle soap web services, we get a SocketTimeout exception when a remote server closes the connection after the payload has been delivered. The problem occurs when the client receives a TLS `close_notify` _after_ the payload has been received. The payload must be larger than the allocated byte buffer receiving the decrypted payload (~16K in the default case). This results in decrypted data being available in the `httpcore-nio` library, but not immediately consumed. When these conditions are met, the following section of code is invoked: `org.apache.cxf.transport.http.asyncclient.SharedInputBuffer#_consumeContent_:111{color`}: ```java if (!this.buffer.hasRemaining() && this.ioctrl != null && !this.endOfStream) { this.ioctrl.suspendInput(); } ``` The suspension of input when combined with the connection close and the following change introduced in `httpcore-nio` 4.4.10 (and it's revised 4.4.11 version here) truly removes the `READ` `EventMask` from the underlying `IOSessionImpl`: `org.apache.http.nio.reactor.ssl.SSLIOSession#_updateEventMask_:402{color`} ```java if (this.endOfStream && (this.appBufferStatus == null || !this.appBufferStatus.hasBufferedInput())) { newMask = newMask & ~EventMask.READ; } ``` Once this happens, requests for input by `SharedInputBuffer#_waitForData(int)_` enter the `_updateEventMask_` method as expected, but the new `httpcore-nio` code above prevents the read operation from being reenabled despite the remainder of the decrypted payload being available in the `SSLIOSession` `inPlain` buffer. The call ultimately fails with a `SocketTimeoutException`. I created a unit test to demonstrate the failure and attached it to the JIRA. Given the complexity of the code and multiple buffers at play, I have not been able to come up with a fix beyond modifying the `SSLIOSession` code above to account for the buffered decrypted content. It seems in all cases where `appBufferStatus.hasBufferedInput()` is queried, `inPlain.hasData()` is also queried, with the exception of the `updateEventMask` code above. Please let me know if there's anything else you need from me. --- **Affects:** 4.4.10, 4.4.11, 4.4.12 **Attachments:** - [asyncbugtest.log](https://issues.apache.org/jira/secure/attachment/12980322/asyncbugtest.log) (_112.24 kB_) - [asyncbugtest.zip](https://issues.apache.org/jira/secure/attachment/12980207/asyncbugtest.zip) (_12.24 kB_) **Issue Links:** - [CXF-8113](https://issues.apache.org/jira/browse/CXF-8113) SocketTimeoutException when remote server closes connection after payload has been delivered **Backported to:** [4.4.13](https://github.com/apache/httpcomponents-core/milestone/50?closed=1) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
