No socket error when network disconnects
Closed this issue · 2 comments
sebakerckhof commented
I have a little testscript like:
var WebSocket = require("faye-websocket");
var url = "ws://10.196.46.53:80/websocket";
var socket = new WebSocket.Client(url, null);
socket.on("open", function() {
console.log("OPEN");
});
socket.on("error", function(error) {
console.log("ERROR",error);
});
socket.on("close", function(event) {
console.log("CLOSE",event.code,event.reason);
});
socket.on("message", function(event) {
console.log("MESSAGE",event.data);
});
If I run it, I get the following output:
OPEN
MESSAGE {"server_id":"0"}
If I disable my network adapter I get following output:
ERROR Network error: ws://10.196.46.53:80/websocket: read ECONNRESET
However, if I just unplug my network cable, I do not get any error notifications...
Both on win7 and debian linux.
jcoglan commented
The client relies on the underliying TCP or TLS stream to report errors/closes. Can you find out which events that object is emitting when you unplug the cable, if any?
sebakerckhof commented
Okay, I thought they did, but apparently TCP or TLS sockets also don't report when a cable is unplugged.
Looks like I'll have to use a hearbeat and detect it myself.