Hi All,
We are currently using AHC version 2.5.4 & noticing the following behavior with respect to timeouts specifically
when setting the below configs -
max_con = 10000;
.setMaxConnections(max_con)
.setRequestTimeout(3000)
.addRequestFilter(new ThrottleRequestFilter(max_con))
We decided to use ThrottleRequestFilter to throttle requests when we hit the max_con limit.
However I noticed that whenever the request times out we get org.asynchttpclient.exception.TooManyConnectionsException.
I tried to dig into the AHC code (specifically ThrottleRequestFilter & MaxConnectionSemaphore) & noticed that they both use different semaphores to
throttle. I am suspecting whether this is causing the TooManyConnectionsException to be thrown specifically when the request times out.
I do not see this exception being thrown when I don't set any timeout for the requests. However our requirement is to support timeout.
I also noticed that few days back support for BlockingConnectionSemaphoreFactory was added in the following PR -
So I pulled the latest AHC and modified my code as follows to use setAcquireFreeChannelTimeout & removed ThrottleRequestFilter.
max_con = 10000;
.setMaxConnections(max_con)
.setRequestTimeout(3000)
.setAcquireFreeChannelTimeout(30000)
Now when I run my test with some timeouts I do not see TooManyConnectionsException being thrown. However after a while I do see
"java.net.SocketException: Too many open files".
The ulimit -n is 100000. I am not sure whether this is an expected behavior.
Regards,
Aditya