Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNTLM Crash with big NPM Project (Windows 10) #114

Open
SunNathan opened this issue May 14, 2024 · 12 comments
Open

CNTLM Crash with big NPM Project (Windows 10) #114

SunNathan opened this issue May 14, 2024 · 12 comments

Comments

@SunNathan
Copy link
Contributor

SunNathan commented May 14, 2024

Hi everyone

Environment :

  • Windows 10
  • Cntlm (master build branch with cygwin 64)
  • NodeJS v20.11.1 & v16.14.0
  • NPM 10.2.4 & 8.19.4

Crash :

It seems that CNTLM crashes when I install a large project with NPM install.
Here are the logs I get (repeated several times) with an NPM on Windows:

  • cntlm: PID 218: write() failed with error 9: Bad file descriptor
  • cntlm: PID 218: No proxy on the list works. You lose.
  • cntlm: PID 218: Proxy connect failed, will try <ourProxy>:3129
  • cntlm: PID 218: no buffer space available

After trying the same procedure, but with CNTLM installed on Linux, it works without crashing the cntlm proxy (by installing the NPM project on Windows and setting the proxy parameter to the Linux server).
However, I get this message:

  • "Too many files open"

It seems that the crash on Windows comes from Cygwin, but I'm not 100% sure. If so, is there a workaround ?

Thank you

@jschwartzenberg
Copy link
Collaborator

I saw crashes with NPM before on RHEL as well, but not anymore with later revisions. It seems NPM generally is quite a stress test.

The main workaround would be to put your local NPM proxy (Artifactory, Nexus, etc.) hostname in the no_proxy and NO_PROXY environment variables so that NPM will not go through CNTLM.

Are you using a PAC file?

@fralken
Copy link
Collaborator

fralken commented May 14, 2024

The "no buffer space available" can mean that there are too many network connections open. It can be a leak, or Cygwin has a limit that is lower than on Linux. I understand that on Linux it works and that the message "Too many files open" appears on Windows.

It is difficult to understand what's going here. Can you provide more details?

@SunNathan
Copy link
Contributor Author

Thank you for your reply,
However I don't use a private NPM repository and it wouldn't be relevant for us to maintain one (considering our usage).

The message "Too many files open" appears only on Linux. (but the proxy doesn't crash)
But the "no buffer space available" message only appears for Windows. (but the proxy crashes)

I think this is due to the fact that NPM has to launch all downloads in parallel ( so it launches a lot of simultaneous connections).
Windows probably supports it less well because of a Cygwin limit (but I haven't found a solution to increase this limit).

@fralken
Copy link
Collaborator

fralken commented May 15, 2024

Maybe NPM opens a huge number of requests that are not closed? It is difficult to figure out what is going on. If you start cntlm with -q you add some debugging log, mainly the requests.

@SunNathan
Copy link
Contributor Author

SunNathan commented May 15, 2024

Here's an example of the logs obtained when attempting to install NPM dependencies.
logs_cntlm.txt

Please note that NPM remains blocked and that when I exit the terminal that launches "npm install", CNTLM shuts down.
However, even when NPM seems to be blocked, I can still use CNTLM with other programs (e.g. Firefox) until I close the NPM console.

EDIT: Here is the message obtained in the CNTLM logs after closing the terminal in which the "NPM Install" was run

forward_request: palive=0, authok=0, ntlm=0, closed=0
Press any key to continue...

@fralken
Copy link
Collaborator

fralken commented May 15, 2024

I see that there is a lot of "proxy connect failed". It would be interesting if you could test this outside the corporate network, that is, with cntlm that works in direct mode (you should run cntlm with "NoProxy *" in the conf file).
The problem can be that if the remote proxy doesn't respond, the connection is not closed and cntlm after many connections goes out of resources.

@SunNathan
Copy link
Contributor Author

I don't think it's due to my remote proxy, in fact if I run a cntlm on a Linux machine and use this CNTLM to install my NPM packets it works.
Moreover, I won't be able to test outside my corporate network (our machines don't allow it).

@fralken
Copy link
Collaborator

fralken commented May 16, 2024

On a Linux machine you said that you got "Too many files open" error but cntlm doesn't crash. It can be a different effect of the same issue, that is, cntlm cannot connect to the remote proxy after many requests.

@SunNathan
Copy link
Contributor Author

Probably, but I don't get a message on the linux CNTLM that it can't connect to the remote proxy. That's why it seems strange to me.

@fralken
Copy link
Collaborator

fralken commented May 16, 2024

You can try this: you set a cntlm on the windows machine that connects to the cntlm on the linux machine that connects to the real proxy. This is to check if the problem is between the windows machine and the real proxy.

So npm connects to cntlm on the same windows machine, cntlm on windows sets the proxy to cntlm on linux, and cntlm on linux sets the proxy to the real corporate proxy.

If the problem persist, we exclude that it is related to the connections with the corporate proxy, but instead it is related to the specific windows implementation (possibly something wrong in cygwin).

@SunNathan
Copy link
Contributor Author

Hello,
I tried to do what you advised, (pointing a CNTLM on Windows directly to a Linux CNTLM which connects to the remote proxy).
Unfortunately, this doesn't change the problem at all.
I've attached the logs.

cntlm_log_2.txt

In summary, here are the logs obtained:

  • cntlm: PID 262: Serious error during accept: No buffer space available
  • cntlm: PID 262: Proxy connect failed, will try :3128
  • cntlm: PID 262: No proxy on the list works. You lose.

@fralken
Copy link
Collaborator

fralken commented May 23, 2024

Well, at least we figured out that it is not a metter of connection with the remote proxy. Probably it is something wrong with Cygwin that maybe in certain cases it does not close connections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants