netty-http-client icon indicating copy to clipboard operation
netty-http-client copied to clipboard

connection reuse issue

Open tanimasaini opened this issue 9 years ago • 3 comments

Hi,

I am using this library to make multiple http calls to a particular host:port. I have configured the client to use keep alive connections and I also send Connection: keep-alive header in the http request.

public static final HttpClient client = HttpClient.builder().threadCount(32) .setChannelOption(ChannelOption.SO_KEEPALIVE, true) .setChannelOption(ChannelOption.SO_REUSEADDR, true) .setChannelOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .followRedirects().build();

However I see that the sockets opened by my application goes on increasing and connections are in established state.

If I send a header Connection: Close in the http request, the sockets are closed and reponed and hence the number of sockets in established state dont increase. This is as expected.

I think due to some reason, the client library is keeping the connection alive but is unable to reuse that connection. Is there any configuration which I am missing? Or there can be a bug in http client code or netty code?

tanimasaini avatar May 26 '15 11:05 tanimasaini

I was waiting for a generic connnection pool to be available in Netty to do connection reuse, which recently became available, and was backported to stable Netty 4.x - so that is now solvable.

In the meantime, I hate to say it, but use Connection: close. I'll probably have some time in a couple of weeks to get to this, but patches are welcome too.

timboudreau avatar May 26 '15 18:05 timboudreau

FYI, you can see work in progress on this on the branch named pool

timboudreau avatar Jun 17 '15 23:06 timboudreau

How's the progress on the pool branch coming along?

simonhf avatar Sep 01 '15 23:09 simonhf