hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: How can I abort an aynsc request using HttpAsyncClient
Date Mon, 17 Feb 2014 09:45:42 GMT
On Mon, 2014-02-17 at 11:23 +0200, Yoram Dayagi (Gmail) wrote:
> I want to start an async GET request for a big file. Then, at some point, while the content
is still being received, I would like to cancel the request from another thread and close
all relevant resources.
> 
> I tried to achieve this behaviour by implementing AsyncByteConsumer and doing something
like the following, but I have the feeling that the connection from the connection pool was
not released:
> 
> …
>         @Override
>         protected void onByteReceived(ByteBuffer buf, IOControl ioctrl) throws IOException
{
> 		…
> 		ioctrl.shutdown();
> 		…
>         }
> …
> 

This looks correct to me. Why do you think the connection was not
released back to the pool? You can run your client with connection
management context logging turned out to find out whether of not the
pool was leaking connections.

http://hc.apache.org/httpcomponents-client-4.3.x/logging.html


> Also, I read in documentation that using “shutdown” on a channel is bad for SSL connections,
where “close” should be called instead.
> 

Given you are shutting down the connection in the middle of an HTTP
exchange I doubt that should matter. 

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message