[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski resolved HTTPCLIENT-2212.
-------------------------------------------
    Fix Version/s: 5.1.4
                   5.2-alpha2
       Resolution: Fixed

> AsyncClientEndpoint is not released upon lease failure
> ------------------------------------------------------
>
>                 Key: HTTPCLIENT-2212
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2212
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (async)
>    Affects Versions: 5.1.3, 5.2-alpha1
>            Reporter: Lubos Husivarga
>            Priority: Major
>             Fix For: 5.1.4, 5.2-alpha2
>
>
> When I use AsyncHttpClient and try to lease an endpoint to host 
> "https://localhost";, I receive javax.net.ssl.SSLHandshakeException exception 
> via callback's failed method. That's ok, because my localhost certificate is 
> not signed by authority.
> The strange thing is that the endpoint is allocated from 
> PoolingAsyncClientConnectionManager, but not released after the connection 
> failure during the endpoint lease operation.
> There is no way to release the endpoint from callback failed method, because 
> there is no reference to it.
> Failing the lease multiple times consumes all available connections from 
> connection manager pool and any further lease operation remains in pending 
> state preventing any other connections to the host.
> example:
>  
> {code:java}
> httpManager = PoolingAsyncClientConnectionManagerBuilder.create()
>         .setDefaultConnectionConfig(ConnectionConfig.custom()
>                 .setTimeToLive(TimeValue.NEG_ONE_MILLISECOND)    //TTL is 
> maximum time one connection can be used,
>                         //then it is closed and new one is opened. Therefore 
> -1 disables TTL and same connection lasts until
>                         //it is actively used. Then closed by 
> IdleConnectionEvictor thread.
>                 .build())
>         .setDefaultTlsConfig(TlsConfig.custom()
>                 .setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
>                 .build())
>         .build();
> httpClient = HttpAsyncClients.createMinimal(
>         H2Config.DEFAULT,
>         Http1Config.DEFAULT,
>         IOReactorConfig.DEFAULT,
>         httpManager);
> httpClient.start();
>  
> HttpHost host = new HttpHost("https", "localhost", 443);
> httpClient.lease(host, new FutureCallback<AsyncClientEndpoint>() {
>                             @Override
>                             public void failed(Exception ex) {
>                             }
>                             
>                             @Override
>                             public void completed(AsyncClientEndpoint result) 
> {
>                             }
>                             
>                             @Override
>                             public void cancelled() {
>                             }
>                         });
>  
> Set<HttpRoute> routes = httpManager.getRoutes();
>         List<RouteStats> stats = new ArrayList<RouteStats>(routes.size());
>         
>         for(HttpRoute route : routes){
>             PoolStats s = httpManager.getStats(route);
>             System.out.println(route.getTargetHost().getHostName());
>             System.out.println(s.getAvailable());
>             System.out.println(s.getLeased());
>             System.out.println(s.getMax());
>             System.out.println(s.getPending());
>         }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

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

Reply via email to