I\'m trying to set timeout on my WebClient, here is the current code :
SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManag
The WebFlux WebClient
doesn't use Apache Commons HTTP Client. Although you might be able to implement one solution via custom ClientHttpConnector
. The existing ReactorClientHttpConnector
is based on the Netty. So, consider to use Netty options to configure the client, e.g.:
ReactorClientHttpConnector connector =
new ReactorClientHttpConnector(options ->
options.option(ChannelOption.SO_TIMEOUT, this.applicationConfig.getHttpClientConnectTimeout()));
or
.onChannelInit(channel -> channel.config().setConnectTimeoutMillis(this.applicationConfig.getHttpClientConnectTimeout()))
UPDATE
We also can use ReadTimeoutHandler
:
.onChannelInit(channel ->
channel.pipeline()
.addLast(new ReadTimeoutHandler(this.applicationConfig.getHttpClientConnectTimeout())))