On Mon, 2018-11-05 at 15:56 +0000, jwhit...@redhat.com wrote:
> Hi,
>  I am attempting to use the client API. Following the documentation
> to
> combine....
> 
> Pooling Connection Manager
> + 
> Multithreaded request execution
> +
> keep-alive
> +
> re-use socket address
> 
>  I want to know how the api should be used to re-use the underlying
> socket. With the aim to avoid sockets in CLOSE_WAIT waiting to
> timeout.
>  My use case is using httpcomponents to benchmark a server.
> 
>  The example code in 2.4. Multithreaded request execution shows the
> CloseableHttpResponse.close() method being called. I find this closes
> the socket on the managed connection respone. That's because
> org.apache.http.impl.execchain.ConnectionHolder.close() releases the
> managed connection but ignores the configured boolean value of
> ConnectionHolder.reusable.
> 
>  Avoiding the call to CloseableHttpResponse.close() means the
> underlying connection is never released to the pool.
> 

This is incorrect. The underlying connections gets released back to the
connection pool as soon as the response message content gets fully
consumed (processed). CloseableHttpResponse#close aborts the connection
only when the client code fails to consume the response message content
in its entirety. For details see:

http://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/fundamentals.html#d5e145

Oleg 


>  To me this seems broken.
> 
>  I'd expect to find a visible releaseConnection method on the
> response
> object. The body honouring how to handle the underlying resources and
> the managed connection released to the pool.
> 
>  I looked for an example but found none. How is this supposed to work
> ?
> 
> Regards,
> Jeremy Whiting
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
> 


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

Reply via email to