android - Detect WebSocket connection closed -
i'm using node.js , websocket-node build simple chat websocket server.
the client android app.
the server have communicate clients in 2 way:
- websocket message when client connected (app open in foreground)
- push notification using google gcm else
but there little problem need figure out..
when client connected server , internet connection drops, server not notified because client did not send closing frame.. 10 seconds, server thinks connection still alive.
if in 10 seconds server send message on socket.. message can never reach client.
i need detect when connection closed, or way send message using gcm when connection it's closed.
is there way?
from side of server unclean disconnect (no disconnect messages sent) indistinguishable slow connection.
what need have sort of heartbeat. websockets has pings on protocol level this. if library exposes this, set ping delay willing accept, , add handler when fails/doesn't complete after timeout.
Comments
Post a Comment