vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

httpclient connectTimeout does not work expected

Open jinwik opened this issue 3 years ago • 7 comments

Questions

httpclient sets connecttimeout, when the connection fails (possibly due to network jitter or upstream performance issues), the duration of connect failed callback may be less than the connecttimeout.

CircuitBreaker '****' recorded an error: 'io.netty.channel.ConnectTimeoutException: connection timed out: */'. Elapsed time: 1 ms io.netty.channel.ConnectTimeoutException: connection timed out: ** at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:267) at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38) at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:127) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

Version

3.6.x - 3.9.x

Do you have a reproducer?

https://gist.github.com/jinwik/569938388962a457a93ee87d9b9c6732

jinwik avatar Feb 12 '21 00:02 jinwik

update the reproducer

jinwik avatar Feb 13 '21 00:02 jinwik

+1 for this issue, we're reproducing this more in Microsoft Azure cloud and less in AWS. We configured the timeout to be at 10 seconds and we get the error after 200/300ms sometimes. Thanks.

rusuionut avatar Mar 24 '21 10:03 rusuionut

can you elaborate more precisely what the issue is ?

vietj avatar Mar 25 '21 10:03 vietj

vertx httpclient or webclient sets the connection timeout, for example 5 seconds, sometimes it failed and throws io.netty.channel.ConnectTimeoutException but the whole request time is much less than the configured value, for example 1ms, it is so weird.

jinwik avatar Mar 25 '21 10:03 jinwik

I'm seeing this as well with setConnectTimeout(2000) and actual timeouts sometimes taking less than 300ms.

tfemiani-godaddy avatar Apr 01 '21 19:04 tfemiani-godaddy

I think in 4.1 we should add a connection acquisition timeout and have the global timeout only for the HTTP request operation, now this is possible with the new pool implementation.

vietj avatar Apr 26 '21 12:04 vietj

I am not able to reproduce this with this reproducer locally, can you check this still applies with latest vertx 4?

vietj avatar Nov 09 '23 14:11 vietj

other than that, it seems to be a netty issue

vietj avatar Nov 09 '23 14:11 vietj