[ 
https://issues.apache.org/jira/browse/HTTPCORE-718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17574234#comment-17574234
 ] 

Sajinie Kavindya edited comment on HTTPCORE-718 at 8/2/22 1:18 PM:
-------------------------------------------------------------------

[~olegk],

So, according to the above explanation, could you please justify the below 
observations as well?
 * I have written a simple backend to send a chunked response along with the 
*Connection: keep-alive* header. Just after sending the response, it closes the 
connection.
 * I have modified the NHttpClient class to send *two* consecutive requests to 
the backend. Also, updated the pool properties as below and the connection 
timeout to 30s. Also, removed the _ioReactor.shutdown();_ method at the end.
 ** pool.setDefaultMaxPerRoute(1);
pool.setMaxTotal(1);

 * I have tried this in this latest 4.x.x branch (4.4.16-SNAPSHOT). 
[^HttpNIOTestClient_new.zip]

I can see the below two behaviors.
 # The second request fails with the ConnectionClosedException.

{code:java}
Backend server started!
server chunk size: 1412
server chunk size: 0
Closed the backend!
https://localhost:7005-> completed
https://localhost:7005->org.apache.http.ConnectionClosedException: Connection 
is closed
{code}
 # Sometimes, the second request fails with the SocketTimeoutException

{code:java}
Backend server started!
server chunk size: 1412
server chunk size: 0
Closed the backend!
https://localhost:7005-> completed
https://localhost:7005->java.net.SocketTimeoutException: 30,000 milliseconds 
timeout on connection 127.0.0.1:52583<->127.0.0.1:7005
{code}
Please _*do not*_ consider this query as I'm reporting a bug (regression). This 
is me trying to understand how the HttpCore works internally. Maybe the above 
observation is due to some other issue in my test. Kindly explain to me if so. 
Highly appreciate your time!

Thanks,
Sajinie


was (Author: JIRAUSER293031):
[~olegk],

So, according to the above explanation, could you please justify the below 
observations as well?
 * I have written a simple backend to send a chunked response along with the 
*Connection: keep-alive* header. Just after sending the response, it closes the 
connection.
 * I have modified the NHttpClient class to send *two* consecutive requests to 
the backend. Also, updated the pool properties as below and the connection 
timeout to 30s. Also, removed the _ioReactor.shutdown();_ method at the end.
 ** pool.setDefaultMaxPerRoute(1);
pool.setMaxTotal(1);

 * I have tried this in this latest 4.x.x branch (4.4.16-SNAPSHOT). 
[^HttpNIOTestClient_new.zip]

I can see the below two behaviors.
 # The second request fails with the ConnectionClosedException.

{code:java}
Backend server started!
server chunk size: 1412
server chunk size: 0
Closed the backend!
https://localhost:7005-> completed
https://localhost:7005->org.apache.http.ConnectionClosedException: Connection 
is closed
{code}
 # Sometimes, the second request fails with the SocketTimeoutException

{code:java}
Backend server started!
server chunk size: 1412
server chunk size: 0
Closed the backend!
https://localhost:7005-> completed
https://localhost:7005->java.net.SocketTimeoutException: 30,000 milliseconds 
timeout on connection 127.0.0.1:52583<->127.0.0.1:7005
{code}
Please{*}{{*}} _*do not*_ consider this query as I'm reporting a bug 
(regression). This is me trying to understand how the HttpCore works 
internally. Kindly explain to me if I have done anything wrong here. Highly 
appreciate your time!

Thanks,
Sajinie

> Getting org.apache.http.ConnectionClosedException after httpcore-nio version 
> upgrade
> ------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-718
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-718
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.4.15
>         Environment: Java version: 11.0.15.1
> OS: macOS Monterey (Version 12.12.1) 
>            Reporter: Sajinie Kavindya
>            Priority: Major
>         Attachments: HttpNIOTestClient-1.zip, HttpNIOTestClient.zip, 
> HttpNIOTestClient_new.zip
>
>
> 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:
> {code:java}
> org.apache.http.ConnectionClosedException: Connection closed 
> unexpectedly{code}
> 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|http://example.com]
> Thanks & Regards,
> Sajinie
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to