In case the link between a node.js server and a client gets broken, and the disconnection event has not been triggered by a timeout yet, is there any way to detect if a particular event emitted on the client-side could not be delivered to the server side by Socket.IO?
I had a deeper look into this, as I am not an expert on socket.io or node.js.
sockets.io abstracts which method it uses to connect to the server, depending on the browser capabilities. The default is to use WebSockets (HTML5).
sockets.io on the server side however attaches to the webserver of node.js, and so it will always use TCP, since that's what HTTP runs on. So whichever method the client is using it will always use TCP underneath. So you don't need to worry about UDP sockets.
TCP theoretically checks that each packet arrives, and so TCP should bubble up connection errors to the socket.io library. So you might try something like:
<script>
var socket = io.connect('http://localhost/');
socket.on('error', function (message) {
alert( 'error in transport: ' + message );
});
BTW, I haven't tried this myself, but I read the code of socket.io.js (which you should find through your browser as this is dynamically created by socket.io depending on the config of transports, it seems to me) saw which events are emitted using publish(). An error should also trigger a disconnect, reconnect sequence, but the 'close' doesn't fire till its absolutely closed (it looks to me) which might take some time. But it looks like the error
should fire immediately.