Re-establishing web-socket for PWA

I have a PWA shortcut for my app. When people re-access the website from the shortcut, if the PWA was already open and running in the background, the websocket will have been disconnected, so data will not update on their screen. This is a catastrophic issue, as the user might be staring at days old data without even knowing. It will not update until they either quit and reopen the PWA, or restart their phone.

Page refreshes will re-establish the websocket connection, however I don’t know how to detect whether the websocket is severed.

Is there a way to detect websocket status so a page refresh can be triggered? Or even better, Is there a way to re-establish the websocket connection without refreshing the page?


I’m struggling with this too. It’s an old problem never solved:

I’m trying this:

Apparently the writing to the db wakes up the websocket connection without the need of reloading.
I’m saying “apparently” as it works in 90% of my tests but in some cases I still have problems :sob:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.