Possible solutions
Configure maxIdleTime on the ConnectionProvider
ConnectionProvider connectionProvider = ConnectionProvider.builder("custom")
.maxIdleTime(Duration.ofSeconds(60))
.build();
HttpClient httpClient = HttpClient.create(connectionProvider);
WebClient webClient = WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
Set Timeouts on the HttpClient
HttpClient httpClient = HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
.responseTimeout(Duration.ofSeconds(60));
Disable TCP Keep-Alive
HttpClient httpClient = HttpClient.create()
.option(ChannelOption.SO_KEEPALIVE, false);
You also might have more useful logs by changing log level for Netty
logging:
level:
reactor.netty.http.client: DEBUG