Which exception is thrown on connect and socket timeouts of Spring's WebClient?

Viewed 268

I'm setting connect, socket, read and write timeouts via a reactor.netty.tcp.TcpClient as in the following code snippet. On read or write timeouts a io.netty.handler.timeout.ReadTimeoutException or WriteTimeoutException is thrown.

Which exception is thrown for connect and socket timeouts?

// configuration of timeouts
HttpClient httpClient = HttpClient.create()
    .tcpConfiguration(client -> client
        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 2_000)
        //.option(ChannelOption.SO_TIMEOUT, 2_000) // SO_TIMEOUT not supported
        .doOnConnected(conn -> conn
            .addHandlerLast(new ReadTimeoutHandler(2_000, TimeUnit.MILLISECONDS))
            .addHandlerLast(new WriteTimeoutHandler(2_000, TimeUnit.MILLISECONDS))));
ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);

// build the web client
WebClient webClient = WebClient.builder()
    .clientConnector(connector)
    .baseUrl("http://localhost:8081")
    .build();

// perform the GET-request (throws ReadTimeoutException, WriteTimeoutException)
List<MyEntity> responseList = this.nominatimWebClient.get()
                    .uri("/query")
                    .retrieve().bodyToMono(new ParameterizedTypeReference<List<MyEntity>>() {}).block();

EDIT: This warning appeared in my log, so I don't use SO_TIMEOUT anymore:

io.netty.bootstrap.Bootstrap: Unknown channel option 'SO_TIMEOUT' for channel '[id: 0xbb2d06f5]'
0 Answers
Related