{"action":"created","issue":{"url":"https://api.github.com/repos/primus/primus/issues/350","repository_url":"https://api.github.com/repos/primus/primus","labels_url":"https://api.github.com/repos/primus/primus/issues/350/labels{/name}","comments_url":"https://api.github.com/repos/primus/primus/issues/350/comments","events_url":"https://api.github.com/repos/primus/primus/issues/350/events","html_url":"https://github.com/primus/primus/issues/350","id":59800001,"number":350,"title":"Android devices keep reconnecting when screen is turned off","user":{"login":"ookke","id":237161,"avatar_url":"https://avatars.githubusercontent.com/u/237161?v=3","gravatar_id":"","url":"https://api.github.com/users/ookke","html_url":"https://github.com/ookke","followers_url":"https://api.github.com/users/ookke/followers","following_url":"https://api.github.com/users/ookke/following{/other_user}","gists_url":"https://api.github.com/users/ookke/gists{/gist_id}","starred_url":"https://api.github.com/users/ookke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ookke/subscriptions","organizations_url":"https://api.github.com/users/ookke/orgs","repos_url":"https://api.github.com/users/ookke/repos","events_url":"https://api.github.com/users/ookke/events{/privacy}","received_events_url":"https://api.github.com/users/ookke/received_events","type":"User","site_admin":false},"labels":[{"id":44930670,"url":"https://api.github.com/repos/primus/primus/labels/bug","name":"bug","color":"fc2929","default":true},{"id":62602424,"url":"https://api.github.com/repos/primus/primus/labels/%E2%98%85%E2%98%85%E2%98%85","name":"★★★","color":"f1f1f1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2015-03-04T13:52:54Z","updated_at":"2016-12-22T02:46:28Z","closed_at":null,"body":"This is a similar issue to https://github.com/primus/primus/issues/348\n\nBasically it seems that Chrome on Android will leave websockets open but it will suspend timers completely when the screen is turned off. This causes the device to get disconnected when the heartbeat times out on the server side and it will keep reconnecting and getting disconnected because the heartbeat timer is not running on the client side.\n\nThis is not a major issue but it still spams our logs with unnecessary reconnects and it will also affect our users battery life a bit I guess.\n\nSome random ideas:\n\na) Run a \"are we sleeping\" timer that updates a timestamp every x seconds, if last timestamp is > x seconds ago we know that the device is probably sleeping and we don't need to bother reconnecting until we are awake again. Awake can be similarly triggered when we notice that the setInterval is firing again after a delay.\n\nb) Apparently timers in webworkers are immune to suspend/tab in background to some degree: http://stackoverflow.com/a/12522580 so in theory at least we could use webworkers for more reliable timers when available, haven't tested if this is valid for mobile devices though.\n"},"comment":{"url":"https://api.github.com/repos/primus/primus/issues/comments/268704592","html_url":"https://github.com/primus/primus/issues/350#issuecomment-268704592","issue_url":"https://api.github.com/repos/primus/primus/issues/350","id":268704592,"user":{"login":"utan","id":654690,"avatar_url":"https://avatars.githubusercontent.com/u/654690?v=3","gravatar_id":"","url":"https://api.github.com/users/utan","html_url":"https://github.com/utan","followers_url":"https://api.github.com/users/utan/followers","following_url":"https://api.github.com/users/utan/following{/other_user}","gists_url":"https://api.github.com/users/utan/gists{/gist_id}","starred_url":"https://api.github.com/users/utan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utan/subscriptions","organizations_url":"https://api.github.com/users/utan/orgs","repos_url":"https://api.github.com/users/utan/repos","events_url":"https://api.github.com/users/utan/events{/privacy}","received_events_url":"https://api.github.com/users/utan/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T02:46:28Z","updated_at":"2016-12-22T02:46:28Z","body":"I see, but was the \"background\" property added or was just a comment?\r\nConfused..."}}
{"actor":{"display_login":"utan"}}