Small question regarding Spring Webflux Webclient, and how to increase the client side time out please.
Setup, I am the client, I need to consume a third party API over the web.
This third party API is known to be flaky. For a same request, same response, sometimes, it takes 1-2sec, sometimes more than 4-5secs (mostly 4-5secs 😛)
But it is a good and important API, the payload response is very important.
Hence, I believe it is worth to “wait them longer”.
May I ask how to do that please?
After investigation, this third party API do see some 499 response from their VIP.
I believe this means “I did not want to wait”. But I do want to wait longer!
After looking at the Webclient API, I am having a hard time finding how to do this.
Currently, I am constructing my WebClient as such:
WebClient.create().mutate().defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE, HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).clientConnector(new ReactorClientHttpConnector(HttpClient.create().metrics(true, () -> new MicrometerChannelMetricsRecorder(SERVICE, HTTP)).wiretap(true).secure(sslContextSpec -> sslContextSpec.sslContext(getSslContextBuilder())))).build()
What is the current default time out?
How to increase it please via property or code?
Something like :
Many thanks for your help
Per answer from Netty Team, it needs:
.responseTimeout(Duration.ofSeconds(10)) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10 * 1000)
For an example to wait 10 seconds
Are not needed