bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
54 stars 10 forks source link

"Older ports file present." and "Failed to contact ntlm-proxy." when running cypress-ntlm #93

Closed kmassicotte closed 4 years ago

kmassicotte commented 4 years ago

Hello!

I had an early version of this plugin working, but it seems that I'm unable to contact the ntlm-proxy with the latest versions of Cypress (3.7.0) and cypress-ntlm-auth (2.0.5).

Log output on DEBUG=cypress:plugin:ntlm-auth $(npm bin)/ntlm-proxy command:

  cypress:plugin:ntlm-auth SSO is not supported +0ms
  cypress:plugin:ntlm-auth NTLM auth config API listening on port: 40667 +16ms
  cypress:plugin:ntlm-auth NTLM auth proxy listening on port: 40535 +43ms
  cypress:plugin:ntlm-auth wrote /home/vagrant/.config/cypress-ntlm-auth/cypress-ntlm-auth.port +2ms
  cypress:plugin:ntlm-auth Startup done! +0ms
  cypress:plugin:ntlm-auth { configApiUrl: 'http://127.0.0.1:40667',
  cypress:plugin:ntlm-auth   ntlmProxyUrl: 'http://127.0.0.1:40535' } +0ms

In another terminal tab, on DEBUG=cypress:plugin:ntlm-auth $(npm bin)/cypress-ntlm:

  cypress:plugin:ntlm-auth Older ports file present. Waiting 2000 ms for new proxy instance to remove it. +0ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +2s
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +210ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +227ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +211ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +210ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +211ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +210ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +210ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +211ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +210ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +206ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +213ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +216ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +211ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +213ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +206ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +210ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +213ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +208ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +218ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +212ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +206ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +209ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +274ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +254ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +206ms
  cypress:plugin:ntlm-auth Failed to contact ntlm-proxy. May just have been removed. Retrying... +207ms
ERROR: ntlm-proxy must be started before this command

I searched through the issues but haven't found something similar. Any ideas?

Kind regards, KM

bjowes commented 4 years ago

Hi @kmassicotte - based on your logs it seems that the old ntlm-proxy instance is too slow to remove the portsfile. The plugin then picks up the old ports file and tries to connect to it, but it is already closed.

To validate this, you could reverse the launch order - start cypress-ntlm first and then start the proxy (cypress-ntlm will wait up to 15 seconds for the proxy to be available).

I think the plugins startup logic needs to be reconsidered, this is the seconds issue related to timing during startup.

kmassicotte commented 4 years ago

Hi @bjowes , tried that approach this morning but encountering the same behaviour. The "failed to contact ntlm-proxy" logs occur once I've run ntlm-proxy in the other tab.

bjowes commented 4 years ago

This is really weird! Could you try launching the ntlm-proxy and then sending a request to it (using curl or postman for instance). Use the configApiUrl from the logs of the ntlm-proxy and add /alive to it, send as a GET request. As an example, using the logs in your first post, you would do a GET request to http://127.0.0.1:40667/alive. The ntlm-proxy should respond to that, and that is also how cypress-ntlm tries to connect to it.

Since cypress-ntlm can't connect, I am suspecting you have a firewall interfering with the traffic. If this is the case, the described GET request above should fail too.

kmassicotte commented 4 years ago

Indeed, after investigating more, curl was returning the gateway html but Insomnia was returning 200 OK. The issue was an incorrectly set no_proxy value.

Sorry for the trouble and thanks for your help!