Fix socket error handling during client unbind
The client now blackholes any socket errors after sending an unbind. This prevents servers which issue RST from causing unecessary errors for what was a succesful operation. Fix mcavage/node-ldapjs#217
This commit is contained in:
parent
b70bdaa26b
commit
9ec6184ef5
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue