connection reuse issue
tanimasaini opened this issue · 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?
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.
FYI, you can see work in progress on this on the branch named pool
How's the progress on the pool branch coming along?