I'm using ldapjs as a client and I would like to gracefully close the connection when I'm done performing my query. I can't find a way to do this. Is it possible? Thanks!
I'm in the same case, seems like I'm suffering a connection leak :(
Are you guys are using SSL and getting a "ECONNRESET" which crashes node? If so I was previously having the same issue and did 2 things
process.on('uncaughtException', function (err) {
if (err.code === "ECONNRESET") {
console.log(err.stack);
} else {process.exit;}
})
I should also add I've had similar issues with TLS outside of ldapjs
No, in my case just found it was a problem with passport ldap strategy. Unbind is working OK and actually closing connections in the right way. Passport was leaking connections cause my implementation wasn't unbinding connections.
The ldap client has an undocumented method called destroy that will close the connection and not allow reconnection
https://github.com/mcavage/node-ldapjs/blob/master/lib/client/client.js#L974
Thank you ! Calling client.destroy() inside the search callback closes the connection.
Is doing client.destroy() a right thing to do?
Won't destroying the connection and again recreating it, affect the performance.
I'm using client.destroy() presently but not sure of the right way. Maybe reusing the same connection is ideal...
After i tried the option reconnect: true i could find that once the connection is reset its getting connected again. This may be a right thing to do but need further inputs from all...
@prajnavantha Are you getting the ECONNRESET error with the reconnect: true option?
No... I'm not getting an ECONNRESET after reconnect: true. It seems to be working fine. I'm still observing though.
Closing as the documentation is clarified in #393. Please open a new issue if you have further questions.
Most helpful comment
The ldap client has an undocumented method called
destroythat will close the connection and not allow reconnectionhttps://github.com/mcavage/node-ldapjs/blob/master/lib/client/client.js#L974