JeffWScott
JeffWScott2mo ago

Websocket status

My react web Convex app will sometimes become unresponsive. I notice it mainly when opening my phone and trying to use the app like I did before I turned it off. For simplicity sake lets say I have a button that runs a counter mutation. The button will just not work and I feel like it's because the websocket disconnected while my phone was off and hasn't reconnected. Refreshing the webpage will make everything work again. What's the pattern here because this is kind of a show stopper. My users won't know why the button isn't working or why and having them have to refresh the page is a weird workaround. Is there some state I can get that tells me the websocket is disconnected or reconnecting and will the websocket automatically try and reconnect when the webapp is displayed?
2 Replies
Sara
Sara2mo ago
Great Question, If you head over to the change logs of the convex backend, a "connectionState" has been introduced in 1.25.0 I believe, where I believe you can subscribe to the events and handle it how you want see :https://docs.convex.dev/api/classes/react.ConvexReactClient#subscribetoconnectionstate
JeffWScott
JeffWScottOP2mo ago
Thank you!!! Is there a way to initiate this aside from refrshing the page?

Did you find this page helpful?