title: How to set a timeout in Spring 5 WebFlux WebClient
body: <p>I'm trying to set timeout on my WebClient, here is the current code : </p>
  
  <pre><code>SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
  
  ClientHttpConnector httpConnector = new ReactorClientHttpConnector(opt -&gt; {
      opt.sslContext(sslContext);
      HttpClientOptions option = HttpClientOptions.builder().build();
      opt.from(option);
  });
  return WebClient.builder().clientConnector(httpConnector).defaultHeader("Authorization", xxxx)
                  .baseUrl(this.opusConfig.getBaseURL()).build();
  </code></pre>
  
  <p>I need to add timeout and also pooling strategy, I was thinking of something like that : </p>
  
  <pre><code>PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
  cm.setMaxTotal(this.applicationConfig.getHttpClientMaxPoolSize());
  cm.setDefaultMaxPerRoute(this.applicationConfig.getHttpClientMaxPoolSize());
  cm.closeIdleConnections(this.applicationConfig.getServerIdleTimeout(), TimeUnit.MILLISECONDS);
  
  RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(this.applicationConfig.getHttpClientSocketTimeout())
          .setConnectTimeout(this.applicationConfig.getHttpClientConnectTimeout())
          .setConnectionRequestTimeout(this.applicationConfig.getHttpClientRequestTimeout()).build();
  
  CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).setConnectionManager(cm).build();
  </code></pre>
  
  <p>But I can't figure out how to set the httpClient in my webclient </p>