Skip to content

Commit

Permalink
DnsNameResolver: Limit connect timeout to query timeout (#13778)
Browse files Browse the repository at this point in the history
Motivation:

We should not use the default connect timeout (10s) but better use the
query timeout as the limit

Modifications:

Use query timeout as connect timeout if any is configured

Result:

Faster failing connect timeouts when using TCP fallback
  • Loading branch information
normanmaurer committed Jan 12, 2024
1 parent 3370c4e commit 09ba8c3
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ public DnsNameResolver(
.channelFactory(socketChannelFactory)
.attr(DNS_PIPELINE_ATTRIBUTE, Boolean.TRUE)
.handler(TCP_ENCODER);
if (queryTimeoutMillis > 0 && queryTimeoutMillis <= Integer.MAX_VALUE) {
// Set the connect timeout to the same as queryTimeout as otherwise it might take a long
// time for the query to fail in case of a connection timeout.
socketBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) queryTimeoutMillis);
}
}
switch (this.resolvedAddressTypes) {
case IPV4_ONLY:
Expand Down

0 comments on commit 09ba8c3

Please sign in to comment.