I think this is solved by Stop reconnecting when page is hidden by SteffenDE · Pull Request #6534 · phoenixframework/phoenix · GitHub - please try it using the branch from GitHub linked in the PR and hopefully we’ll have this properly fixed in the next release! During testing, I did NOT see the device doing a full page reload though, it only reconnected the socket, so there might be something else in play as well. I think the full reload might happen if there was a deploy in between, then it would be expected iirc.
I’ve been testing this with an Android device + USB debugging to attach to the devtools and inspect what’s happening when the device goes to sleep. Previously, we’d immediately try to connect again. In the WebSocket case the socket would stay in connecting state indefinitely and when unlocking the device the actual connection would take a very long time (for no apparent reason). For LongPoll, the device would backoff the HTTP requests and then also when unlocking the actual connection could take a very long time to actually send data (I ran tcpdump on the server side).
The fix prevents trying to reconnect when the page indicates that it is hidden and only does a new connection attempt as soon as it’s visible again. For both WebSocket and LongPoll, I can’t reproduce the stalling in that case. The page reconnects instantly as it should.






















