-
Notifications
You must be signed in to change notification settings - Fork 421
Connection management (Client API) #317
Comments
Correct, ldapjs consumers are expected to use the The client documentation is admittedly lacking. I've been trying to improve it over time. |
Thanks for the reply. const ldapPool = new Pool(
// create function
cb => {
const client = ldap.createClient({url: process.env.LDAP})
client.once('connect', () => cb(null, client))
client.once('error', err => cb(err))
},
// destroy function
client => {
client.unbind(function noop() {})
},
10, // max connections
ms('1 hour'), // max idle time
ms('10 seconds') // min time between reconnects
) |
Generally speaking, yes. Events which cause the client to become unavailable should be emitted via the There are (albeit poorly documented) built-in mechanisms in the client for reconnect and idleness detection. You might want to look around in the source code. |
Please include a minimal reproducible example |
The docs don't name any way to manage the connection. If you just do
without a running server on port 9000 will crash the process with an ECONNREFUSED. Looking at the source code, to prevent this, you would have to attach an onerror listener and check for ECONNREFUSED. If you want to make sure the connection is established, you apparently need to listen for
connect
. None of this is mentioned in the docs :(I saw that there is a
connect()
method that is automatically called when the LdapClient is created. But it doesn't take a callback. In other modules like node-mysql you can create the connection object first and then callconnect()
with a callback that gets called when the connection is established or with an error.Similar to this, how do you close the connection? In other modules you have
close()
orend()
with a callback.(Btw thank you for making/maintaining this module, LDAP is so essential for my applications, without it NodeJS wouldn't be an option)
The text was updated successfully, but these errors were encountered: