Allow to update connectionParams #504
-
StoryWe are using a single client (with a single websocket connection) for multiple subscriptions. Authentication/verify of the token works great with "onConnect" as in the server. As our tokens are short-lived (5min) we are currently forced to close the websocket/client regularly - also because we (server-side) verify the token for every subscription with "onSubscribe" - however the context provided for onSubscribe is the one given for the connection-init. After 5min that token is expired. We like to suggest to add a function updateConnectionParams that just resend the values to the server, and let the server store the updated object in it's context. Acceptance criteriaUser can use short-lived tokens for server-sided verifications inside onSubscribe long after the client has established the websocket connection to the server. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The connection parameters are intentionally long lived alongside the connection and should not be updated, the GraphQL over WebSocket spec even disallows multiple To get different parameters in the context, you close and have the client reconnect - as you already do. If you don't want to close the connection, but do want to send some metadata to the server: you should use client-side pings and populate the payload. The "client usage with manual pings and pongs" recipe might help you out to get going. Hope this helps! |
Beta Was this translation helpful? Give feedback.
The connection parameters are intentionally long lived alongside the connection and should not be updated, the GraphQL over WebSocket spec even disallows multiple
ConnectionInit
messages.To get different parameters in the context, you close and have the client reconnect - as you already do.
If you don't want to close the connection, but do want to send some metadata to the server: you should use client-side pings and populate the payload. The "client usage with manual pings and pongs" recipe might help you out to get going.
Hope this helps!