Retry on fatal closure best practices #323
-
Hi! I've seen in the docs / issues that retries will be limited to codes that are considered to be non fatal. Given those rules I was wondering what you all would suggest for retrying in the event that a JWT has expired and the socket is closed with 4400? The recipe for graceful restart seems like a good starting place but I'm working on a project where the token refresh is fairly quick and it seems overkill to be constantly reconnecting. Curious what would be the best practice or if an existing pattern to cover this scenario already exists! Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Alternatively you can use the GraphQL over WebSocket Protocol pings and pongs to transmit the refresh token. This way you would keep pinging the server from the client with the necessary credentials in the payload, the server would validate each ping's credentials and proceed accordingly (if valid noop, if invalid close connection). Recipes "Client usage with manual pings and pongs" and "Server usage with ws and subprotocol pings and pongs" should help you get started. |
Beta Was this translation helpful? Give feedback.
Alternatively you can use the GraphQL over WebSocket Protocol pings and pongs to transmit the refresh token. This way you would keep pinging the server from the client with the necessary credentials in the payload, the server would validate each ping's credentials and proceed accordingly (if valid noop, if invalid close connection).
Recipes "Client usage with manual pings and pongs" and "Server usage with ws and subprotocol pings and pongs" should help you get started.