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

Oleg Kalnichevski commented on HTTPCORE-777:
--------------------------------------------

[~oleksandrkriuchenko] 
 # Here's the fix for the problem of the request futures not being cancelled 
during the client shutdown [1]
 # I am not sure about the original problem though. What I see is that the mock 
server _fails_ to establish a connection. It basically does not respond to the 
connection request at all. Eventually the request future correctly timeout and 
the test passes for me.

{noformat}
DEBUG 
[main][org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient] 
ex-0000000001 preparing request execution
DEBUG [main][org.apache.hc.client5.http.impl.async.AsyncProtocolExec] 
ex-0000000001 target auth state: UNCHALLENGED
DEBUG [main][org.apache.hc.client5.http.impl.async.AsyncProtocolExec] 
ex-0000000001 proxy auth state: UNCHALLENGED
DEBUG [main][org.apache.hc.client5.http.impl.async.AsyncConnectExec] 
ex-0000000001 acquiring connection with route {}->[http://httpbin.org:1080]
DEBUG [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] 
ex-0000000001 acquiring endpoint (3 MINUTES)
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] 
ex-0000000001 endpoint lease request (3 MINUTES) [route: 
{}->[http://httpbin.org:1080]][total available: 0; route allocated: 0 of 5; 
total allocated: 0 of 25]
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] 
ex-0000000001 endpoint leased [route: {}->[http://httpbin.org:1080]][total 
available: 0; route allocated: 1 of 5; total allocated: 1 of 25]
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] 
ex-0000000001 acquired ep-0000000001
DEBUG [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] 
ex-0000000001 acquired endpoint ep-0000000001
DEBUG [main][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient] 
ep-0000000001 connecting endpoint (null)
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] 
ep-0000000001 connecting endpoint to http://httpbin.org:1080 (15 SECONDS)
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.DefaultAsyncClientConnectionOperator]
 http://httpbin.org:1080 connecting null->null (15 SECONDS)
DEBUG [main][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester] 
httpbin.org resolving remote address
DEBUG [main][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester] 
httpbin.org resolved to [httpbin.org/44.205.219.248, httpbin.org/44.196.147.43, 
httpbin.org/54.144.47.213, httpbin.org/34.205.201.49]
DEBUG [main][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester] 
httpbin.org:1080 connecting null->httpbin.org/44.205.219.248:1080 (15 SECONDS)
DEBUG 
[httpclient-dispatch-1][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connection to httpbin.org/44.205.219.248:1080 failed (class 
java.net.SocketTimeoutException); retrying connection to the next address
DEBUG 
[httpclient-dispatch-1][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connecting null->httpbin.org/44.196.147.43:1080 (15 SECONDS)
DEBUG 
[httpclient-dispatch-2][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connection to httpbin.org/44.196.147.43:1080 failed (class 
java.net.SocketTimeoutException); retrying connection to the next address
DEBUG 
[httpclient-dispatch-2][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connecting null->httpbin.org/54.144.47.213:1080 (15 SECONDS)
DEBUG 
[httpclient-dispatch-3][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connection to httpbin.org/54.144.47.213:1080 failed (class 
java.net.SocketTimeoutException); retrying connection to the next address
DEBUG 
[httpclient-dispatch-3][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connecting null->httpbin.org/34.205.201.49:1080 (15 SECONDS)
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester]
 httpbin.org:1080 connection to httpbin.org/34.205.201.49:1080 failed (class 
java.net.SocketTimeoutException); terminating operation
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient]
 ex-0000000001 request failed: Connect to http://httpbin.org:1080 
[httpbin.org/44.205.219.248, httpbin.org/44.196.147.43, 
httpbin.org/54.144.47.213, httpbin.org/34.205.201.49] failed: 15 SECONDS
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager]
 ep-0000000001 close IMMEDIATE
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient]
 ep-0000000001 endpoint closed
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient]
 ep-0000000001 discarding endpoint
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager]
 ep-0000000001 releasing endpoint
DEBUG 
[httpclient-dispatch-4][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager]
 ep-0000000001 connection released [route: {}->[http://httpbin.org:1080]][total 
available: 0; route allocated: 0 of 5; total allocated: 0 of 25]
GET 
http://httpbin.org:1080/->org.apache.hc.client5.http.ConnectTimeoutException: 
Connect to http://httpbin.org:1080 [httpbin.org/44.205.219.248, 
httpbin.org/44.196.147.43, httpbin.org/54.144.47.213, 
httpbin.org/34.205.201.49] failed: 15 SECONDS
DEBUG [main][org.apache.hc.client5.http.impl.async.AbstractHttpAsyncClientBase] 
Shutdown GRACEFUL
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] 
Shutdown connection pool GRACEFUL
DEBUG 
[main][org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager] 
Connection pool shut down
{noformat}
One set a shorter connect timeout by configuring the connection manager
{code:java}
private CloseableHttpAsyncClient buildClient() {
    return HttpAsyncClients.custom()
            
.setConnectionManager(PoolingAsyncClientConnectionManagerBuilder.create()
                    .setDefaultConnectionConfig(ConnectionConfig.custom()
                            .setConnectTimeout(Timeout.ofSeconds(15))
                            .build())
                    .build())
            .build();
}
{code}
As far as I can tell HttpClient works correctly.

Oleg

[1] 
[https://github.com/apache/httpcomponents-core/compare/5.3.x...ok2c:httpcomponents-core:HTTPCORE-777]

> CloseableHttpAsyncClient.execute hangs forever upon connection reset
> --------------------------------------------------------------------
>
>                 Key: HTTPCORE-777
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-777
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 5.3.3
>            Reporter: Oleksandr Kriuchenko
>            Priority: Major
>
> There seems to be an issue with async http client request execution: 
> if connection is closed during request execution then the future 
> returned by the CloseableHttpAsyncClient.execute never completes.
> Please find a test setup to reproduce the issue (along with the 
> conditions description under which the issue reproduces) in 
> [https://github.com/oleksandr-kriuchenko-lohika/httpcore5-issue]



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to