Skip to content

Latest commit

 

History

History
697 lines (565 loc) · 29.8 KB

http-client.adoc

File metadata and controls

697 lines (565 loc) · 29.8 KB

HTTP Client

Reactor Netty provides the easy-to-use and easy-to-configure HttpClient. It hides most of the Netty functionality that is required to create an HTTP client and adds Reactive Streams backpressure.

Connect

To connect the HTTP client to a given HTTP endpoint, you must create and configure a HttpClient instance. The following example shows how to do so:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/connect/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/connect/Application.java[role=include]
  1. Creates a HttpClient instance ready for configuring.

  2. Specifies that GET method will be used.

  3. Specifies the path.

  4. Obtains the response HttpClientResponse

The following example uses WebSocket:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/websocket/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/websocket/Application.java[role=include]

Host and Port

In order to connect to a specific host and port, you can apply the following configuration to the HTTP client:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/address/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/address/Application.java[role=include]
  1. Configures the HTTP host

  2. Configures the HTTP port

Eager Initialization

By default, the initialization of the HttpClient resources happens on demand. This means that the first request absorbs the extra time needed to initialize and load:

  • the event loop group

  • the host name resolver

  • the native transport libraries (when native transport is used)

  • the native libraries for the security (in case of OpenSsl)

When you need to preload these resources, you can configure the HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/warmup/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/warmup/Application.java[role=include]
  1. Initialize and load the event loop group, the host name resolver, the native transport libraries and the native libraries for the security

  2. Host name resolution happens with the first request. In this example, a connection pool is used, so with the first request the connection to the URL is established, the subsequent requests to the same URL reuse the connections from the pool.

Writing Data

To send data to a given HTTP endpoint, you can provide a Publisher by using the send(Publisher) method. By default, Transfer-Encoding: chunked is applied for those HTTP methods for which a request body is expected. Content-Length provided through request headers disables Transfer-Encoding: chunked, if necessary. The following example sends hello:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/send/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/send/Application.java[role=include]
  1. Sends a hello string to the given HTTP endpoint

Adding Headers and Other Metadata

When sending data to a given HTTP endpoint, you may need to send additional headers, cookies and other metadata. You can use the following configuration to do so:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/send/headers/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/send/headers/Application.java[role=include]
  1. Disables Transfer-Encoding: chunked and provides Content-Length header.

Compression

You can enable compression on the HTTP client, which means the request header Accept-Encoding is added to the request headers. The following example shows how to do so:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/compression/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/compression/Application.java[role=include]

Auto-Redirect Support

You can configure the HTTP client to enable auto-redirect support.

Reactor Netty provides two different strategies for auto-redirect support:

  • followRedirect(boolean): Specifies whether HTTP auto-redirect support is enabled for statuses 301|302|303|307|308. When it is 303 status code, GET method is used for the redirect.

  • followRedirect(BiPredicate<HttpClientRequest, HttpClientResponse>): Enables auto-redirect support if the supplied predicate matches.

The following example uses followRedirect(true):

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/redirect/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/redirect/Application.java[role=include]

Consuming Data

To receive data from a given HTTP endpoint, you can use one of the methods from HttpClient.ResponseReceiver. The following example uses the responseContent method:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/read/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/read/Application.java[role=include]
  1. Receives data from a given HTTP endpoint

  2. Aggregates the data

  3. Transforms the data as string

Reading Headers and Other Metadata

When receiving data from a given HTTP endpoint, you can check response headers, status code, and other metadata. You can obtain this additional metadata by using HttpClientResponse. The following example shows how to do so.

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/read/status/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/read/status/Application.java[role=include]
  1. Obtains the status code.

HTTP Response Decoder

By default, Netty configures some restrictions for the incoming responses, such as:

  • The maximum length of the initial line.

  • The maximum length of all headers.

  • The maximum length of the content or each chunk.

For more information, see HttpResponseDecoder

By default, the HTTP client is configured with the following settings:

./../../reactor-netty-http/src/main/java/reactor/netty/http/HttpDecoderSpec.java
link:./../../reactor-netty-http/src/main/java/reactor/netty/http/HttpDecoderSpec.java[role=include]
./../../reactor-netty-http/src/main/java/reactor/netty/http/client/HttpResponseDecoderSpec.java
link:./../../reactor-netty-http/src/main/java/reactor/netty/http/client/HttpResponseDecoderSpec.java[role=include]

When you need to change these default settings, you can configure the HTTP client as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/responsedecoder/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/responsedecoder/Application.java[role=include]
  1. The maximum length of all headers will be 16384. When this value is exceeded, a TooLongFrameException is raised.

Lifecycle Callbacks

The following lifecycle callbacks are provided to let you extend the HttpClient.

Callback Description

doAfterRequest

Invoked when the request has been sent.

doAfterResolve

Invoked after the remote address has been resolved successfully.

doAfterResponseSuccess

Invoked after the response has been fully received.

doOnChannelInit

Invoked when initializing the channel.

doOnConnect

Invoked when the channel is about to connect.

doOnConnected

Invoked after the channel has been connected.

doOnDisconnected

Invoked after the channel has been disconnected.

doOnError

Invoked when the request has not been sent and when the response has not been fully received.

doOnRedirect

Invoked when the response headers have been received, and the request is about to be redirected.

doOnRequest

Invoked when the request is about to be sent.

doOnRequestError

Invoked when the request has not been sent.

doOnResolve

Invoked when the remote address is about to be resolved.

doOnResolveError

Invoked in case the remote address hasn’t been resolved successfully.

doOnResponse

Invoked after the response headers have been received.

doOnResponseError

Invoked when the response has not been fully received.

The following example uses the doOnConnected and doOnChannelInit callbacks:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/lifecycle/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/lifecycle/Application.java[role=include]
  1. Netty pipeline is extended with ReadTimeoutHandler when the channel has been connected.

  2. Netty pipeline is extended with LoggingHandler when initializing the channel.

TCP-level Configuration

When you need configurations on a TCP level, you can use the following snippet to extend the default TCP client configuration (add an option, bind address etc.):

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/channeloptions/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/channeloptions/Application.java[role=include]
  1. Configures the connection establishment timeout to 10 seconds.

  2. Enables TCP keepalive. This means that TCP starts sending keepalive probes when a connection is idle for some time.

  3. The connection needs to remain idle for 5 minutes before TCP starts sending keepalive probes.

  4. Configures the time between individual keepalive probes to 1 minute.

  5. Configures the maximum number of TCP keepalive probes to 8.

See [tcp-client] for more about TCP level configurations.

SSL and TLS

When you need SSL or TLS, you can apply the configuration shown in the next example. By default, if OpenSSL is available, a SslProvider.OPENSSL provider is used as a provider. Otherwise, a SslProvider.JDK provider is used You can switch the provider by using SslContextBuilder or by setting -Dio.netty.handler.ssl.noOpenSsl=true. The following example uses SslContextBuilder:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/security/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/security/Application.java[role=include]

Server Name Indication

By default, the HTTP client sends the remote host name as SNI server name. When you need to change this default setting, you can configure the HTTP client as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/sni/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/sni/Application.java[role=include]

Retry Strategies

By default, the HTTP client retries the request once if it was aborted on the TCP level.

HTTP/2

By default, the HTTP client supports HTTP/1.1. If you need HTTP/2, you can get it through configuration. In addition to the protocol configuration, if you need H2 but not H2C (cleartext), you must also configure SSL.

Note
As Application-Layer Protocol Negotiation (ALPN) is not supported “out-of-the-box” by JDK8 (although some vendors backported ALPN to JDK8), you need an additional dependency to a native library that supports it — for example, netty-tcnative-boringssl-static.

The following listing presents a simple H2 example:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/http2/H2Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/http2/H2Application.java[role=include]
  1. Configures the client to support only HTTP/2

  2. Configures SSL

The following listing presents a simple H2C example:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/http2/H2CApplication.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/http2/H2CApplication.java[role=include]

Protocol Selection

./../../reactor-netty-http/src/main/java/reactor/netty/http/HttpProtocol.java
link:./../../reactor-netty-http/src/main/java/reactor/netty/http/HttpProtocol.java[role=include]

Metrics

The HTTP client supports built-in integration with Micrometer. It exposes all metrics with a prefix of reactor.netty.http.client.

The following table provides information for the HTTP client metrics:

metric name type description

reactor.netty.http.client.data.received

DistributionSummary

Amount of the data received, in bytes

reactor.netty.http.client.data.sent

DistributionSummary

Amount of the data sent, in bytes

reactor.netty.http.client.errors

Counter

Number of errors that occurred

reactor.netty.http.client.tls.handshake.time

Timer

Time spent for TLS handshake

reactor.netty.http.client.connect.time

Timer

Time spent for connecting to the remote address

reactor.netty.http.client.address.resolver

Timer

Time spent for resolving the address

reactor.netty.http.client.data.received.time

Timer

Time spent in consuming incoming data

reactor.netty.http.client.data.sent.time

Timer

Time spent in sending outgoing data

reactor.netty.http.client.response.time

Timer

Total time for the request/response

These additional metrics are also available:

The following table provides information for the HTTP client metrics when it is configured to serve HTTP/2 traffic:

metric name type description

reactor.netty.connection.provider.active.streams

Gauge

The number of the active HTTP/2 streams

reactor.netty.connection.provider.pending.streams

Gauge

The number of requests that are waiting for opening HTTP/2 stream

The following example enables that integration:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/metrics/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/metrics/Application.java[role=include]
  1. Applies upper limit for the meters with URI tag

  2. Templated URIs will be used as a URI tag value when possible

  3. Enables the built-in integration with Micrometer

Note
In order to avoid a memory and CPU overhead of the enabled metrics, it is important to convert the real URIs to templated URIs when possible. Without a conversion to a template-like form, each distinct URI leads to the creation of a distinct tag, which takes a lot of memory for the metrics.
Note
Always apply an upper limit for the meters with URI tags. Configuring an upper limit on the number of meters can help in cases when the real URIs cannot be templated. You can find more information at maximumAllowableTags.

When HTTP client metrics are needed for an integration with a system other than Micrometer or you want to provide your own integration with Micrometer, you can provide your own metrics recorder, as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/metrics/custom/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/metrics/custom/Application.java[role=include]
  1. Enables HTTP client metrics and provides HttpClientMetricsRecorder implementation.

Unix Domain Sockets

The HTTP client supports Unix Domain Sockets (UDS) when native transport is in use.

The following example shows how to use UDS support:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/uds/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/uds/Application.java[role=include]
  1. Specifies DomainSocketAddress that will be used

Host Name Resolution

By default, the HttpClient uses Netty’s domain name lookup mechanism that resolves a domain name asynchronously. This is as an alternative of the JVM’s built-in blocking resolver.

When you need to change the default settings, you can configure the HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/resolver/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/resolver/Application.java[role=include]
  1. The timeout of each DNS query performed by this resolver will be 500ms.

The following listing shows the available configurations:

Configuration name Description

cacheMaxTimeToLive

The max time to live of the cached DNS resource records (resolution: seconds). If the time to live of the DNS resource record returned by the DNS server is greater than this max time to live, this resolver ignores the time to live from the DNS server and uses this max time to live. Default to Integer.MAX_VALUE.

cacheMinTimeToLive

The min time to live of the cached DNS resource records (resolution: seconds). If the time to live of the DNS resource record returned by the DNS server is less than this min time to live, this resolver ignores the time to live from the DNS server and uses this min time to live. Default: 0.

cacheNegativeTimeToLive

The time to live of the cache for the failed DNS queries (resolution: seconds). Default: 0.

completeOncePreferredResolved

When this setting is enabled, the resolver notifies as soon as all queries for the preferred address type are complete. When this setting is disabled, the resolver notifies when all possible address types are complete. This configuration is applicable for DnsNameResolver#resolveAll(String). By default, this setting is enabled.

disableOptionalRecord

Disables the automatic inclusion of an optional record that tries to give a hint to the remote DNS server about how much data the resolver can read per response. By default, this setting is enabled.

disableRecursionDesired

Specifies whether this resolver has to send a DNS query with the recursion desired (RD) flag set. By default, this setting is enabled.

hostsFileEntriesResolver

Sets a custom HostsFileEntriesResolver to be used for hosts file entries. Default: DefaultHostsFileEntriesResolver.

maxPayloadSize

Sets the capacity of the datagram packet buffer (in bytes). Default: 4096.

maxQueriesPerResolve

Sets the maximum allowed number of DNS queries to send when resolving a host name. Default: 16.

ndots

Sets the number of dots that must appear in a name before an initial absolute query is made. Default: -1 (to determine the value from the OS on Unix or use a value of 1 otherwise).

queryTimeout

Sets the timeout of each DNS query performed by this resolver (resolution: milliseconds). Default: 5000.

resolvedAddressTypes

The list of the protocol families of the resolved address.

bindAddressSupplier

The supplier of the local address to bind to.

roundRobinSelection

Enables an AddressResolverGroup of DnsNameResolver that supports random selection of destination addresses if multiple are provided by the nameserver. See RoundRobinDnsAddressResolverGroup. Default: DnsAddressResolverGroup

runOn

Performs the communication with the DNS servers on the given LoopResources. By default, the LoopResources specified on the client level are used.

searchDomains

The list of search domains of the resolver. By default, the effective search domain list is populated by using the system DNS search domains.

trace

A specific logger and log level to be used by this resolver when generating detailed trace information in case of resolution failure.

Sometimes, you may want to switch to the JVM built-in resolver. To do so, you can configure the HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/resolver/custom/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/resolver/custom/Application.java[role=include]
  1. Sets the JVM built-in resolver.

Timeout Configuration

This section describes various timeout configuration options that can be used in HttpClient. Configuring a proper timeout may improve or solve issues in the communication process. The configuration options can be grouped as follows:

Connection Pool Timeout

By default, HttpClient uses a connection pool. When a request is completed successfully and if the connection is not scheduled for closing, the connection is returned to the connection pool and can thus be reused for processing another request. The connection may be reused immediately for another request or may stay idle in the connection pool for some time.

The following list describes the available timeout configuration options:

  • maxIdleTime - The maximum time (resolution: ms) that this connection stays idle in the connection pool. By default, maxIdleTime is not specified.

Note
When you configure maxIdleTime, you should consider the idle timeout configuration on the target server. Choose a configuration that is equal to or less than the one on the target server. By doing so, you can reduce the I/O issues caused by a connection closed by the target server.
  • maxLifeTime - The maximum time (resolution: ms) that this connection stays alive. By default, maxLifeTime is not specified.

  • pendingAcquireTimeout - The maximum time (resolution: ms) after which a pending acquire operation must complete, or a PoolAcquireTimeoutException is thrown. Default: 45s.

By default, these timeouts are checked on connection release or acquire operations and, if some timeout is reached, the connection is closed and removed from the connection pool. However, you can also configure the connection pool, by setting evictInBackground, to perform periodic checks on connections.

To customize the default settings, you can configure HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/pool/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/pool/config/Application.java[role=include]
  1. Configures the maximum time for a connection to stay idle to 20 seconds.

  2. Configures the maximum time for a connection to stay alive to 60 seconds.

  3. Configures the maximum time for the pending acquire operation to 60 seconds.

  4. Every two minutes, the connection pool is regularly checked for connections that are applicable for removal.

HttpClient Timeout

This section provides information for the various timeout configuration options at the HttpClient level.

Note
Reactor Netty uses Reactor Core as its Reactive Streams implementation, and you may want to use the timeout operator that Mono and Flux provide. Keep in mind, however, that it is better to use the more specific timeout configuration options available in Reactor Netty, since they provide more control for a specific purpose and use case. By contrast, the timeout operator can only apply to the operation as a whole, from establishing the connection to the remote peer to receiving the response.

Response Timeout

HttpClient provides an API for configuring a default response timeout for all requests. You can change this default response timeout through an API for a specific request. By default, responseTimeout is not specified.

Note
It is always a good practice to configure a response timeout.

To customize the default settings, you can configure HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/read/timeout/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/read/timeout/Application.java[role=include]
  1. Configures the default response timeout to 1 second.

  2. Configures a response timeout for a specific request to 2 seconds.

Connection Timeout

The following listing shows all available connection timeout configuration options, but some of them may apply only to a specific transport.

  • CONNECT_TIMEOUT_MILLIS - If the connection establishment attempt to the remote peer does not finish within the configured connect timeout (resolution: ms), the connection establishment attempt fails. Default: 30s.

  • SO_KEEPALIVE - When the connection stays idle for some time (the time is implementation dependent, but the default is typically two hours), TCP automatically sends a keepalive probe to the remote peer. By default, SO_KEEPALIVE is not enabled. When you run with Epoll/NIO (since Java 11 on Mac or Linux) transport, you may also configure:

    • TCP_KEEPIDLE - The maximum time (resolution: seconds) that this connection stays idle before TCP starts sending keepalive probes, if SO_KEEPALIVE has been set. The maximum time is implementation dependent, but the default is typically two hours.

    • TCP_KEEPINTVL (Epoll)/TCP_KEEPINTERVAL (NIO) - The time (resolution: seconds) between individual keepalive probes.

    • TCP_KEEPCNT (Epoll)/TCP_KEEPCOUNT (NIO) - The maximum number of keepalive probes TCP should send before dropping the connection.

Note
Sometimes, between the client and the server, you may have a network component that silently drops the idle connections without sending a response. From the Reactor Netty point of view, in this use case, the remote peer just does not respond. To be able to handle such a use case you may consider configuring SO_KEEPALIVE.

To customize the default settings, you can configure HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/channeloptions/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/channeloptions/Application.java[role=include]
  1. Configures the connection establishment timeout to 10 seconds.

  2. Enables TCP keepalive. This means that TCP starts sending keepalive probes when a connection is idle for some time.

  3. The connection needs to remain idle for 5 minutes before TCP starts sending keepalive probes.

  4. Configures the time between individual keepalive probes to 1 minute.

  5. Configures the maximum number of TCP keepalive probes to 8.

SSL/TLS Timeout

HttpClient supports the SSL/TLS functionality provided by Netty.

The following list describes the available timeout configuration options:

  • handshakeTimeout - Use this option to configure the SSL handshake timeout (resolution: ms). Default: 10s.

Note
You should consider increasing the SSL handshake timeout when expecting slow network connections.
  • closeNotifyFlushTimeout - Use this option to configure the SSL close_notify flush timeout (resolution: ms). Default: 3s.

  • closeNotifyReadTimeout - Use this option to configure the SSL close_notify read timeout (resolution: ms). Default: 0s.

To customize the default settings, you can configure HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/security/custom/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/security/custom/Application.java[role=include]
  1. Configures the SSL handshake timeout to 30 seconds.

  2. Configures the SSL close_notify flush timeout to 10 seconds.

  3. Configures the SSL close_notify read timeout to 10 seconds.

Proxy Timeout

HttpClient supports the proxy functionality provided by Netty and provides a way to specify the connection establishment timeout. If the connection establishment attempt to the remote peer does not finish within the timeout, the connection establishment attempt fails. Default: 10s.

To customize the default settings, you can configure HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/proxy/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/proxy/Application.java[role=include]
  1. Configures the connection establishment timeout to 20 seconds.

Host Name Resolution Timeout

By default, the HttpClient uses Netty’s domain name lookup mechanism to resolve a domain name asynchronously.

The following list describes the available timeout configuration options:

  • cacheMaxTimeToLive - The maximum time to live of the cached DNS resource records (resolution: seconds). If the time to live of the DNS resource record returned by the DNS server is greater than this maximum time to live, this resolver ignores the time to live from the DNS server and uses this maximum time to live. Default: Integer.MAX_VALUE.

  • cacheMinTimeToLive - The minimum time to live of the cached DNS resource records (resolution: seconds). If the time to live of the DNS resource record returned by the DNS server is less than this minimum time to live, this resolver ignores the time to live from the DNS server and uses this minimum time to live. Default: 0s.

  • cacheNegativeTimeToLive - The time to live of the cache for the failed DNS queries (resolution: seconds). Default: 0s.

  • queryTimeout - Sets the timeout of each DNS query performed by this resolver (resolution: milliseconds). Default: 5s.

To customize the default settings, you can configure HttpClient as follows:

./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/resolver/Application.java
link:./../../reactor-netty-examples/src/main/java/reactor/netty/examples/documentation/http/client/resolver/Application.java[role=include]
  1. The timeout of each DNS query performed by this resolver will be 500ms.