Package org.xbill.DNS

Class DohResolver

All Implemented Interfaces:
Resolver

public final class DohResolver extends DohResolverCommon
Proof-of-concept DNS over HTTP (DoH) resolver. This class is not suitable for high load scenarios because of the shortcomings of Java's built-in HTTP clients. For more control, implement your own Resolver using e.g. OkHttp.

On Java 8, it uses HTTP/1.1, which is against the recommendation of RFC 8484 to use HTTP/2 and thus slower. On Java 11 or newer, HTTP/2 is always used, but the built-in HttpClient has its own issues with connection handling.

As of 2020-09-13, the following limits of public resolvers for HTTP/2 were observed:

  • https://cloudflare-dns.com/dns-query: max streams=250, idle timeout=400s
  • https://dns.google/dns-query: max streams=100, idle timeout=240s
  • Since:
    3.0
    • Field Details

    • Constructor Details

      • DohResolver

        public DohResolver(String uriTemplate)
        Creates a new DoH resolver that performs lookups with HTTP GET and the default timeout (5s).
        Parameters:
        uriTemplate - the URI to use for resolving, e.g. https://dns.google/dns-query
      • DohResolver

        public DohResolver(String uriTemplate, int maxConcurrentRequests, Duration idleConnectionTimeout)
        Creates a new DoH resolver that performs lookups with HTTP GET and the default timeout (5s).
        Parameters:
        uriTemplate - the URI to use for resolving, e.g. https://dns.google/dns-query
        maxConcurrentRequests - Maximum concurrent HTTP/2 streams for Java 11+ or HTTP/1.1 connections for Java 8. On Java 8 this cannot exceed the system property http.maxConnections.
        idleConnectionTimeout - Max. idle time for HTTP/2 connections until a request is serialized. Applies to Java 11+ only.
        Since:
        3.3
    • Method Details