How to keep WebSocket connection alive in Chrome for Android when page is hidden?

Viewed 54

I have a web app which receives notifications through websocket connection and displays them using the Notification API. When chrome tab is hidden the websocket connection is frozen after few minutes, thus interrupting notifications.

To solve this I tried to move the notifier along with the websocket connection to a web worker. First I tried Service Worker, but it's not usable for stateful code since their state is lost very often, it's granted to survive only when its event handlers are called.

I tried Dedicated Worker, but they have same lifecycle as the owning web page, when the page inactive the worker is also frozen.

I was going to try SharedWorker but I found it's not supported in Chrome for Android.

0 Answers
Related