Safari dropping web socket connection due to inactivity when page not in focus
Problem
You want to: [x] report a bug [ ] request a feature Current behaviour Not sure if this is a known issue (I tried searching but found nothing). Safari for Mac appears to be silently dropping websocket connections due to inactivity/idle if the page/tab is not in focus. Steps to reproduce (if the current behaviour is a bug) Make Safari tab/page not in focus; log websocket events. Expected behaviour Websockets should be kept alive via the heartbeat functionality. Not seeing this behavior in other browsers so unlikely to be my code. Setup - OS: Mac OSX 10.12.4 (16E195) - browser: Safari 10.1 (12603.1.30.0.34) - socket.io version: 1.7.3 Other information (e.g. stacktraces, related issues, suggestions how to fix) Is this possibly some sort of power-saving feature that is overriding/ignoring the heartbeats?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Safari dropping web socket connection due to inactivity when page not in focus
@twistedpixel the reconnection delay is exponential (that is, something like: wait 500ms, try reconnect, wait 1000ms, try reconnect...) (source), so that may explain the behaviour. How about forcing to reconnect when the window gets the focus again? [code block] It may be related to https://github.com/primus/primus/issues/348.
Trust Score
4 verifications
- 1
@twistedpixel the reconnection delay is exponential (that is, something like: wa
@twistedpixel the reconnection delay is exponential (that is, something like: wait 500ms, try reconnect, wait 1000ms, try reconnect...) (source), so that may explain the behaviour.
- 2
How about forcing to reconnect when the window gets the focus again?
How about forcing to reconnect when the window gets the focus again?
- 3
It may be related to https://github.com/primus/primus/issues/348.
It may be related to https://github.com/primus/primus/issues/348.
Validation
Resolved in socketio/socket.io GitHub issue #2924. Community reactions: 7 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep