Skip to content

Detecting when a websocket connection is down #493

Answered by enisdenjo
kpysniak asked this question in Q&A
Discussion options

You must be logged in to vote

The client automatically performs silent reconnects when the connection is abruptly closed. By default, it retries 5 times using randomised exponential backoff. You can disable the retries by setting the retryAttempts client option to zero (0).

Furthermore, you can listen for the closed event for when the WebSocket connection closes.

P.S. there is no reconnect option in the client.

    const wsLink = new GraphQLWsLink(
      createClient({
        url: process.env.NEXT_PUBLIC_WEBSOCKET_DATAGATE_ADDRESS,
-       reconnect: true,
        lazy: false,
        connectionParams: () => {
          return {
            headers: {
              Authorization: token,
            },
          };
  …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by enisdenjo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #492 on July 17, 2023 09:55.