New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incoming message not waking phone when asleep. #81
Comments
@chrisdew Websocket connection have a keep-alive mechanism (ping/pong), that does not run while phone sleeps. So the server drops the connection when not receiving an pong from the client for a while. |
@chrisdew Depending on server-side and/or client-side configuration, a TCP connection is automatically closed if no data is transmitted through the connection. To put it the other way around, if data is transmitted periodically before the automatic close is triggered, the connection is kept alive. In the WebSocket layer, Ping/Pong mechanism can be used for the purpose. If either the server or the client sends Ping (or Pong) frames periodically, the WebSocket connection (which is a kind of TCP connection) is kept alive. nv-websocket-client library provides However, the following two are different things in different layers.
So, even if an application sends Ping frames periodically, an underlying operating system may drop the connection while the phone is asleep. How to prevent an underlying operating system from dropping TCP connections while the phone is asleep varies depending on operating systems. The behavior cannot be controlled in the WebSocket layer. |
This seems to be an operating system / platform issue. I don't think it can be controlled in the WebSocket layer. Please reopen this issue if necessary. |
Two or three years ago I wrote an app which opened a TCP connection. When it was asleep, an incoming TCP packet, over GPRS, would wake the phone enough for a TCP response to be sent, with no wakelocks required.
I'm trying to do the same thing over websockets now, but the websocket connections are being dropped while the phone sleeps.
Why is this, and what can I do to get TCP-like behaviour when the phone is asleep?
The text was updated successfully, but these errors were encountered: