0

I have two interdependent webclient calls to different api's , when the first webclient call response is delayed then readtimeout excpetion is coming . but whenever the first call is success and the second call response is delayed then it is waiting for response indefinitely.

i tried creating seperate instances of webclient for each call . still issue persists.

HttpClient httpClient = HttpClient.create()
            .tcpConfiguration(client ->

                    client.doOnConnected(conn -> conn
                            .addHandlerLast(new ReadTimeoutHandler(10))
                            .addHandlerLast(new WriteTimeoutHandler(10))));


    return WebClient.builder().baseUrl(url).clientConnector(new ReactorClientHttpConnector(httpClient))
            .exchangeStrategies(ExchangeStrategies.withDefaults())
            .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
            .filter(ExchangeFilterFunctions
                    .basicAuthentication(", "))
            .build();

Two subsequent calls are below where , when the second call is delayed response then the readtimeout exception is not thrown

request = request.flatMap(req ->
                tempService.getId(loggedInUser, token)
      .map(response -> {
                            req.setRetrieveClientIdentifier(response.getId());
                            return seRequest;
                        }))

                .zipWhen(request -> tempService.getIdFor(request.getIdentifier(), accountToken)).map(tuple -> {

                    tuple.getT1().setID(tuple.getT2().getId());
                    return tuple.getT1();
                });
Marko Previsic
  • 1,820
  • 16
  • 30
  • are you sure its a read timeout issue and not a connection timeout issue? https://stackoverflow.com/questions/3069382/what-is-the-difference-between-connection-and-read-timeout-for-sockets try configuring the the connection timeout. https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-client-builder-reactor-timeout – Toerktumlare Jun 25 '19 at 11:18
  • yes i added but still same , My only question irrespective any number of subsequent calls ,the timeout behaviour should work . but in my case for the second subsequent call its not working . TcpClient tcpClient = TcpClient.create() .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutMills) .option(ChannelOption.SO_TIMEOUT, connectTimeoutMills) .doOnConnected(connection -> connection.addHandlerLast(new – Madhu Kundala Jun 25 '19 at 12:43

0 Answers0