0

How are DNS query retries controlled using Simple Resolver in DNSJava? Using the same resolver, we see retries of 2 and in some cases 3. It is not clear as to how it is retried. Any help in this regard?

Update - The attempts are consistent on different machines with the same piece of code.

    SimpleResolver           resolver = (dns == null) ? new SimpleResolver() : new 
    SimpleResolver(dns) ;

    resolver.setTimeout(Duration.ofMillis(dnsTimeoutMs));
    lookup.setResolver(resolver) ;
    lookup.setCache(null);

    org.xbill.DNS.Record[]   records = lookup.run() ;

enter image description here

1 Answer 1

0

Neither the SimpleResolver nor Lookup perform retries, only the ExtendedResolver does that. The only time a query is sent again by the SimpleResolver is when the initial UDP query failed and the fallback to TCP is attempted.

If you attach a logger, e.g. slf4j-simple, and raise the log level to DEBUG, you should see detailed information what's going on.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the response. I have tried capturing network traces and could see that there are 3 attempts being made. However, on other machines, it is making 2 attempts. So, I need to understand the logic of retries. Can you please let me know this point? Note that it is consistently 3 or 2 attempts in different machines. Updated with image above.
What you're seeing is not a retry, these are different queries. The initial request is not for an absolute domain name (i.e. it has no trailing dot). Thus the search path of the machine(s) you're running this on is used (search in Linux' resolv.conf / Primary Dns Suffix on Windows).
If you see the timestamp between the 3 messages, there is an attempt after 2 seconds of timeout for all the 3 cases... The destination DNS server IP is the configured IP.... So, it is attempting to make query to that IP... It is not referring to the IP in resolv.conf file. I understand your point that the initial request is not for an absolute path but the IP it is trying is an external node configured DNS IP and timeout is also 2 secs which is the configured timeout (set using setTimeout function). Do you still see that the attempts are 2 here?
As I said, attach a logger to your application, set the level to debug, and look at the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.