Default read and connection timeouts for reactor-netty HttpClient

Viewed 1751

I know that a read and a connection timeouts can be configured in reactor-netty HttpClient, like:

  public WebClient xsdWebClient() {

    HttpClient httpClient = createHttpClient(config.getConnectionTimeout(), config.getReadTimeout());

    return WebClient.builder()
        .clientConnector(new ReactorClientHttpConnector(httpClient.followRedirect(true)))
        .baseUrl(config.getHost())
        .build();
  }

  private static HttpClient createHttpClient(int connectionTimeout, int readTimeout) {
    return HttpClient.create()
        .option(
            ChannelOption.CONNECT_TIMEOUT_MILLIS,
            (int) TimeUnit.SECONDS.toMillis(connectionTimeout))
        .doOnConnected(c -> c.addHandlerLast(new ReadTimeoutHandler(readTimeout)));
  }

But what are the default read and connection timeouts for reactor-netty HttpClient?

2 Answers

I would recommend you to use the response timeout configuration provided by Reactor Netty instead of ReadTimeoutHandler. You can configure the response timeout either globally on HttpClient level for all requests or per request. The default values for various timeouts provided by Reactor Netty you can find in the reference documentation.

Referring to answer given by one of the devs of reactor-netty, the read default time is 10 seconds.

Related