简体   繁体   中英

Default read and connection timeouts for reactor-netty HttpClient

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?

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM