Reputation: 65
I am developing a application of two-way communication in SocketIO between App of iPhone and server.
Once app user disconnect the socket connection from the application, it was found that it takes about 30 seconds to detect the disconnect event on the server side.
I am in trouble is to not be detected immediately disconnect event on the server side.
To borrow your wisdom.
io.sockets.on('connection', function (socket) {
socket.on('disconnect', function () {
//disconnection process...
});
});
(Server-side) · NodeJS (v0.10.26) - [email protected]
(Client side) · Swift1.6 - SIOSocket · Xcode6.4
Upvotes: 0
Views: 4286
Reputation: 119877
You should handle these:
close
event to the client so that you can detect the disconnection immediately.Network
framework for example) and detect network loss. It is very close to immediate.Upvotes: 0
Reputation: 2564
Unless you explicitly close the socket on the client side with socket.disconnect()
, there is no way to instantly detect disconnection. It was further explained here:
https://stackoverflow.com/a/32009603/5169236
So if your app simply loses internet access, gets closed and wiped from memory etc., and you don't explicitly close the socket, there is no way to detect it instantly.
Upvotes: 1