node-ldapjs icon indicating copy to clipboard operation
node-ldapjs copied to clipboard

v2.0.0.-pre.1: Anyway to get the PID (process ID) without invoking logging client?

Open tfrancois opened this issue 5 years ago • 5 comments

In version of ldapjs prior to the ldapjs@next build, I was able to retrieve the active connection's PID simply by accessing the existing log object without any extra work. I'm not trying to add logging via the support bunyan or pito libraries (as I am not famaliar at all on how to do this effectively - I've tried- and I'm concerned about the unneccessary overhead). At this point, all I really need is the unique PID for the existing ldapjs connection so as to identify if the new latest connection has been re-used or if its a newly spun-up thread/connection to the ldap server. I've looked at the entire returned client object to find it and its nowhere to be found. Thanks in advance!

tfrancois avatar Sep 12 '19 23:09 tfrancois

I ended up learning/understanding how to implement logging with Pino and it solved my issue regarding locating/obtaining the pid. Thank you. Issue closed.

tfrancois avatar Sep 13 '19 21:09 tfrancois

My initial inclination is that what you are describing is a poor way to determine if a new connection is being used. Are you saying that you're referencing this:

https://github.com/ldapjs/node-ldapjs/blob/dadac0c36ca6bfdb34b0ca4963f814ca3610b2f2/lib/client/client.js#L808-L809

jsumners avatar Sep 15 '19 13:09 jsumners

@jsumners Thank you re-opening this question as what I have now come to understand is that the process ID/pid I thought I was obtaining was NOT the correct one. Any pid I’ve come across thus far is the pid of the NodeJS client instance where the code is running, not a PID from the LDAP server.

Can you please advise on what is the best way to determine if a new connection is opened to the LDAP server from my client application when multiple calls/iterations are made in my code? I would really appreciate your input/insight on that? I’ve removed the use of any logger I thought would help since from what I could gather none of their logging references the correct pid I’m looking for.

Unless the previous snippet you’ve referenced in your last reply is the best/only way? Please advise and thank you!

tfrancois avatar Sep 18 '19 02:09 tfrancois

I still don't know what information you are trying to obtain. I did not write this library and so am not familiar with all of its intimate details. I need you to confirm which information you are expecting to be exposed. Either by showing an example of what you expect, confirming the linked snippet generates what you expect, or linking to the code that does generate what you expect.

jsumners avatar Sep 18 '19 11:09 jsumners

Hi @jsumners, sorry if what I'm asking sounds more complicated than it is.

All I am trying to trap/identify if there is a way to determine, either via Pino or the ldapjs library itself, when a new connection is open to the same LDAP server that I am currently connected to. As in MySQL connections, you can have multiple connections to a server from one client if you send multiple requests. I am wondering if there is a way to determine when this is the case with LDAP. Preferably in the form of a PID. That's all I'm asking sir. Any advise please?

tfrancois avatar Sep 18 '19 15:09 tfrancois

👋

On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request.

Please see issue #839 for more information, including how to proceed if you feel this closure is in error.

jsumners avatar Feb 22 '23 19:02 jsumners