Search code examples
spring-bootspring-webfluxwebclient

Is there a preconfigure time out for spring boot WebClient (webflux) for block() request?


I saw somewhere that spring web client will wait 30 seconds by default till it able to establish a connection. this sound resonable so I just use the default.

However, I have api call using web client with block() that it is actually require to wait the called service to finish a task before sending a response, currently I just intruduce Thread.sleep(2 minutes) and the calling service seems to wait which is good but I need to know how it is configure, I need to make sure the data will be process in full.


Solution

  • No there is no default timeout configured for block and its blocked indefinitely until next its resolved.

    https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#block--

    There are alternate methods like with timeout to specify the timeout in Spring WebFlux

    https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#block-java.time.Duration-