79149113

Date: 2024-11-01 18:58:12
Score: 0.5
Natty:
Report link

If you would like to increase the SSL handshake timeout of the HttpClient, you can create a bean and add it in @Configuration annotated class and then autowire(inject) this bean where required in your Service.

@Bean
public WebClient webClient() {
    Http11SslContextSpec http11SslContextSpec = Http11SslContextSpec.forClient();

    HttpClient client = HttpClient.create()
                          .secure(spec -> spec.sslContext(http11SslContextSpec)                                       
                          .handshakeTimeout(Duration.ofSeconds(30));

    WebClient client = WebClient.builder()
            .baseUrl(SOME_BASE_API_URL)
            .clientConnector(new ReactorClientHttpConnector(httpClient))
            .build();

    return client;
}

Reference: https://projectreactor.io/docs/netty/release/reference/index.html#ssl-tls-timeout

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Configuration
  • Low reputation (0.5):
Posted by: Aashutosh Taikar