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

Enable DNS Resolving via TCP in case of Timeout

Open cgm-aw opened this issue 1 year ago • 11 comments

Hi everyone,

I noticed that Vertx enables Netty DNS Resolving via TCP (see https://github.com/eclipse-vertx/vert.x/blob/4.5.17/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java#L108): builder.socketChannelFactory(() -> (SocketChannel) vertx.transport().channelFactory(false).newChannel());

However, this sets "retryOnTimeout" to "false". It would be nice if Vertx would enable TCP resolving on timeouts - maybe just with some kind of environment variable for toggling, like this:

builder.socketChannelFactory(() -> (SocketChannel) vertx.transport().channelFactory(false).newChannel(), Boolean.getBoolean("vertx.dns.retryOnTimeout"));

I'm happy to provide a PR if you approve of this.

Best regards

Contribution

Me

cgm-aw avatar Aug 13 '25 14:08 cgm-aw

By the way, I think https://github.com/eclipse-vertx/vert.x/issues/5114 requests the same thing.

cgm-aw avatar Aug 14 '25 12:08 cgm-aw

@cgm-aw this should be configured using vertx options or address resolver options, contribution is welcome

vietj avatar Sep 01 '25 07:09 vietj

Done: https://github.com/eclipse-vertx/vert.x/pull/5692 I just noticed this is flagged for 5.x, I based the fix on 4.x. Not sure what your policy on backports is - should I base the fix on 5.x?

cgm-aw avatar Sep 01 '25 13:09 cgm-aw

we can backport very small features

vietj avatar Sep 03 '25 08:09 vietj

@cgm-aw can you port this contribution to master ?

vietj avatar May 12 '26 08:05 vietj

Sure, here is the PR for master: https://github.com/eclipse-vertx/vert.x/pull/6116

cgm-aw avatar May 18 '26 08:05 cgm-aw

Hi @cgm-aw / maintainers, I’d like to work on this if it’s still available.

I checked current master and the equivalent call now appears in:

vertx-core/src/main/java/io/vertx/core/dns/impl/DnsAddressResolverProvider.java

My proposed approach:

  • add a Vert.x system property, for example vertx.dns.retryOnTimeout
  • wire it into Netty’s DnsNameResolverBuilder#socketChannelFactory(ChannelFactory, boolean)
  • keep the default behavior unchanged by using false
  • add focused test coverage where feasible, making sure the system property is restored after the test

Does this API shape sound acceptable, or would you prefer this as an AddressResolverOptions property instead of a system property?

codingkiddo avatar May 24 '26 08:05 codingkiddo

system properties must be avoided

vietj avatar May 26 '26 05:05 vietj

Hi @cgm-aw / maintainers, I’d like to work on this if it’s still available.

I checked current master and the equivalent call now appears in:

vertx-core/src/main/java/io/vertx/core/dns/impl/DnsAddressResolverProvider.java

My proposed approach:

  • add a Vert.x system property, for example vertx.dns.retryOnTimeout
  • wire it into Netty’s DnsNameResolverBuilder#socketChannelFactory(ChannelFactory, boolean)
  • keep the default behavior unchanged by using false
  • add focused test coverage where feasible, making sure the system property is restored after the test

Does this API shape sound acceptable, or would you prefer this as an AddressResolverOptions property instead of a system property?

My PR 6116 does exactly that already using the existing Vertx configuration possibilities, @vietj please check if the tests are sufficient for you.

cgm-aw avatar May 26 '26 06:05 cgm-aw

@cgm-aw it is not clear how your contribution is tested, normally the vertx mock dns resolver should implement TCP to implement the test

vietj avatar May 26 '26 07:05 vietj

@vietj I reworked the tests, please check.

cgm-aw avatar Jun 01 '26 14:06 cgm-aw