1

Say you have a socket.io/node.js chatroom. If it's open on a bunch of computers, all seems to work fine indefinitely.

But say you've connected on a phone or tablet, and walk away for a few minutes. Your mobile device has auto-locked and when you reopen your browser, the new messages you see on your PC aren't there and the messages you try and send don't go through.

Is there any well known solution or workaround to making this work well for mobile users?

What exactly is happening? (Socket closed by timeout of mobile os? (would HTTP vs TCP make a difference?))

Thanks for any insights!

TheImpact
  • 191
  • 1
  • 7

1 Answers1

1

Mobile browsers stop javascript execution when they go to sleep without informing javascript.

You can detect when they reawaken with a timer Can any desktop browsers detect when the computer resumes from sleep?

Then you need to have reconnect to the server.

Optionally you can ask for all the messages that occurred while the browser was asleep.

Community
  • 1
  • 1
generalhenry
  • 17,227
  • 4
  • 48
  • 63