What is the correct way to set a (connection) timeout for the (default) WebClient?
Is it enough to just use Mono#timeout(Duration) method on the resulti
For now, WebClient does not offer that option as a top-level configuration option. You have to configure that at the underlying HTTP client library.
So the answer to the other question is right. But in your case, you probably need to change the connection timeout, not the socket timeout (or both).
ReactorClientHttpConnector connector =
new ReactorClientHttpConnector(options ->
options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 2000));
WebClient webClient = WebClient.builder().clientConnector(connector).build();