I\'m using Socket.IO (the latest version 1.1.0) to exchange messages with an Android app (the client). I would like to set a timeout (5s for example) to check if my client
That's not what the timeout setting handles. The timeout is how long the server will wait for a re-connect before it tears down that connection. You probably don't want to set it that short; possibly even leave it at the default.
Socketio automatically sends heartbeats by default. You really should just need to assign a function to run when the 'disconnect' message is received on the server side.
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
Check out this post for more information about the heartbeat: Advantage/disadvantage of using socketio heartbeats