How to retry a Spring WebSocketGraphQlClient query

How to retry a Spring WebSocketGraphQlClient query


0

Using Spring Boot 3.2.4 with Spring WebFlux/GraphQL subscription via Websocket.

Server A exposes a graphqlSubscription, and Server B consumes the subscription.
They both use the same components (reactor/netty).

Steps to Reproduce:

// Client side, Initialize the webSocketGraphQlClient
ReactorNettyWebSocketClient reactorNettyWebSocketClient = new ReactorNettyWebSocketClient(HttpClient.create(), build);
WebSocketGraphQlClient.builder(serverUrl, reactorNettyWebSocketClient).build();
    
// Call sample
webSocketGraphQlClient
 .document(query)
 .retrieveSubscription(path)
 .toEntity(XXXX.class)
 .retryWhen(Retry.fixedDelay(5, Duration.ofMinutes(1))).blockLast()

Not Working Cases

Case 1:

  • Run the client, do not start the server
  • Wait for the 1st RETRY.
  • GraphQlTransportException => connection refused.
  • Run the server.
  • Nexts retries will fail with the same reason.

Case 2:

  • Run the server.
  • Run the client.
  • Communication between both is working fine
  • Kill the server.
  • Wait for the FIRST RETRY
  • WebSocketDisconnectedException -> connection is closed or lost.
  • Wait for the SECOND RETRY.
  • GraphQlTransportException => connection refused.
  • Rerun the server.
  • Nexts retries will fail with the same reason.

Working Case

  • Run the server.
  • Run the client.
  • Communication between both is working fine
  • Kill the server.
  • Wait for the FIRST RETRY
  • WebSocketDisconnectedException -> connection is closed or lost.
  • Rerun the server.
  • OK, the retry is working.

Is there a way to resume a WebSocket connection when the client failed to connect to the remote server?

Link to the github question : https://github.com/spring-projects/spring-graphql/issues/826


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *