-
Hi there, Taking a look at this library as a replacement of websocket to use with urql, looks really cool. Run into the issue in the past with lot of open ws connection to the server, mostly caused by forgotten tabs. Often having to rely on timeout at the load balancer level and limited retry. Any idea or recommendation to solve this issue with this library ? Any equivalent to keepAlive in graphql-ws ? my guess is that a frontend solution is probably more accurate at detecting inactivity, can pause the subscriptions, and let the lazy option automatically close the connection. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey hey, Additionally, both One way of approaching the problem, on the browser, is to simply hook onto some great browser events that help with user activity detection. There are many to choose from, ranging from
How would the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback 👍 Just as a follow up, I tried different things and finally my solution is based on When user inactivity is detected, I use the abortController to interrupt existing connections and delay reconnection until the user come back. If the user do any query or change page, the connection will be reestablished and the subscriptions will work again. It works but it feel a bit dirty, few methods like |
Beta Was this translation helpful? Give feedback.
Hey hey,
graphql-sse
andgraphql-ws
are both in lazy mode by default - they'll establish a connection with the server exclusively if there's a subscription running. I'd say the best way to manage inactive users is to handle it yourself since there's not a single sweet spot that can satisfy everyone.Additionally, both
graphql-sse
andgraphql-ws
are isomorphic, they can run in a browser and in a Node environment. Bundling browser primitives is therefore a no-go. The isomorphic solution here would be to use some magic numbers for inactivity detection, and I don't really like magic in code.One way of approaching the problem, on the browser, is to simply hook onto some great browser events t…