diff --git a/lib/client/client.js b/lib/client/client.js index 5d36213..e6c4ecd 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -853,9 +853,6 @@ Client.prototype.unbind = function unbind(callback) { return callback(); var req = new UnbindRequest(); - if (this.socket.listeners('error').length === 0) { - this.socket.once('error', function () {}); - } return this._send(req, 'unbind', null, callback); }; @@ -1343,6 +1340,10 @@ Client.prototype._sendSocket = function _sendSocket(message, conn.unbindMessageID = message.id; // Mark client as disconnected once unbind clears the socket self.connected = false; + // Some servers will RST the connection after receiving an unbind. + // Socket errors are blackholed since the connection is being closed. + conn.removeAllListeners('error'); + conn.on('error', function () {}); conn.end(); } else if (emitter) { sentEmitter = true;