async-http-client
async-http-client copied to clipboard
Getting TimeoutException
Hi, I have noticed that java.util.concurrent.TimeoutException occures when dealing with AHC. Problem occures when I am executing two request towards same url, first one passes ok but second one timeouts. In case of lets say three request, third being invoked after second timeouts towards same url (and using same method) it passes fine as first one (only second request seems to be problem). Also I have noticed if in AHC config i set .setKeepAlive(false) TimeputException is resolved (not happens). I have created repo on https://github.com/Mark0Sertic/async-http-client-test with test case. There is two TODO comments if you do any of this you avoid getting java.util.concurrent.TimeoutException.
Thank you in advance,
Please try to trim your reproducer to AHC only, eg one hitting a public website (eg google.com). I can't investigate such complex sample that mixing lots of different technologies. Your problem could be in your server as well.
Test case is just using AHC and wiremock as a server and it is just simple spring boot aplication. I can try to remove wiremock and redirect it to google if it is going to help, and will try to kick out Reactor's Monos, I will let you know when i do changes.
This "just" is already too much. For example, your problem could be wiremock not being able to server more than 1 request at a time. Please kick out everything that's not AHC and its deps.
Will do so, I have exclude wiremock from equation because much more complex problem fails in real life production environment. but i understand. I will kick out everything except AHC and let you know when I do it. Thank you.
Your test server is blocking the event loop. So your server is only able to serve one request at a time.
Ok but why is this working if i set in AHC configuration .setKeepAlive(false). If I do that step same test passes without Timeout exception ? If on this line code i add .setKeepAlive(false) test will pass.
Couldn't tell ya. If I had to guess, I'd guess something on your server's side treats that differently and puts those requests on different threads.
This is an issue with your server. If you can't repro this against a real server, but can repro it against your server that is known to be bugged, it's an issue with your server.
Hi thank you for your answer, but have been able to reproduce error, on different servers and also locally. I will try to strip down all dependencies and as suggested reproduce error only using AHC, and after that I will be back with you.
Thank you
@Mark0Sertic this is a bit old, but if you can reproduce I'd be happy to take a look.