diff --git a/lib/server.js b/lib/server.js index d8f24df..88fde04 100644 --- a/lib/server.js +++ b/lib/server.js @@ -146,6 +146,10 @@ Server.prototype.websocketify = function websocketify(req, socket, head) { var client = new Client(req, socket, head, this.options); this.clients[client.id] = client; + // handle socket error to prevent possible app crash, such as ECONNRESET + socket.on('error', function() { + self.error.apply(self, arguments); + }); debug('New LiveReload connection (id: %s)', client.id); client.on('end', function() { debug('Destroy client %s (url: %s)', client.id, client.url); @@ -155,7 +159,7 @@ Server.prototype.websocketify = function websocketify(req, socket, head) { Server.prototype.listen = function listen(port, host, fn) { port = port || this.options.port; - + //Last used port for error display this.port = port;