Liveview does not reconnect when waking phone from sleep

Hello all!

We have noticed some interesting behavior when using our website on a mobile device.

Once someone has let their phone’s screen fall asleep and have had their phone idling for some time (in my testing somewhere around 10 minutes), when they open the browser again to our webpage, the livesocket does not reconnect.

This means that when the user clicks buttons on our forms that emit events for our live view to consume we receive nothing on our backend and there is no interactivity on the page.

The user must (currently) refresh the page for the socket to reconnect and for interactivity to resume.

Is there some sort of best practice for re-establishing this connection? Are we missing some configuration for resuming our connection? Why does the socket not reconnect in this case?

Thank you! :slight_smile:

3 Likes

What browser/platform? What Phoenix and LiveView version?

1 Like

Ah, sorry for the lack of details!

This seems to be occurring (so far accounted) on Safari (iOS) and Brave (Android).

We are using Phoenix 1.6.4 and LiveView version 0.17.5.

1 Like

Can you reliably recreate it? Are you using something like topbar? Is it showing when the page wakes up? Safari supports a remote web inspector if you’re able to recreate it and you can poke at the liveSocket to see what it says, such as liveSocket.isConnected() to verify that you aren’t in fact actually connected, but something else broke like a javascript error. More info would be helpful. I just tried to let mobile Safari (iOS15) sleep a LV tab half a dozen times and was not able to see any reconnection issues, so more info would be helpful.

4 Likes