bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
55 stars 9 forks source link

We received this error at the network level: Error: ESOCKETTIMEDOUT #165

Closed ctan66 closed 3 years ago

ctan66 commented 3 years ago

Hi,

I received this error "We received this error at the network level: > Error: ESOCKETTIMEDOUT"

======================================================================== _cy.visit() failed trying to load:

http://test-url.com/

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

Error: ESOCKETTIMEDOUT

Common situations why this would fail:

Any idea, how to fix it?

Here is the cypress-ntlm logs captured: cypress:plugin:ntlm-auth Adding localhost to NO_PROXY to disable localhost proxying +0ms cypress:plugin:ntlm-auth Adding 127.0.0.1 to NO_PROXY to disable loopback proxying +3ms cypress:plugin:ntlm-auth Starting ntlm-proxy... +1ms cypress:plugin:ntlm-auth NTLM auth config API listening on port: 50325 +15ms cypress:plugin:ntlm-auth NTLM auth proxy listening on port: 50326 +72ms cypress:plugin:ntlm-auth Startup done! +0ms cypress:plugin:ntlm-auth { configApiUrl: 'http://127.0.0.1:50325', cypress:plugin:ntlm-auth ntlmProxyUrl: 'http://127.0.0.1:50326' } +0ms cypress:plugin:ntlm-auth Opening Cypress... +5ms

cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:50337 to target https://download.cypress.io:443/ +10s cypress:plugin:ntlm-auth Request to https://download.cypress.io:443/ - pass on +1ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:50337 due to socket.close +761ms GET // 200 17.067 ms - - GET /cypress/runner/cypress_runner.css 200 3.849 ms - - GET /__cypress/runner/cypress_runner.js 200 1.814 ms - - GET /cypress/iframes/integration/test/intake.js 200 17.493 ms - 923 GET /cypress/runner/fonts/fa-solid-900.woff2 200 20.281 ms - 76120 GET /cypress/tests?p=cypress%5Cintegration%5Celm%5Cforecast-intake.js 200 3216.828 ms - - GET /cypress/tests?p=cypress%5Csupport%5Cindex.js 200 3474.988 ms - - cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:50361 to target http://127.0.0.1:50325/ +10s cypress:plugin:ntlm-auth Request to config API +2ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:50325/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +63ms cypress:plugin:ntlm-auth Added new hosts [ 'test-url.com' ] +4ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:50363 to target http://test-url.com.com:80/ +86ms cypress:plugin:ntlm-auth Request to http://test-url.com:80/ in registered NTLM Hosts +3ms
cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:50361 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:50363 due to socket.close +25s

bjowes commented 3 years ago

Hi @ctan66

Do you own the domain "test-url.com", or are you aliasing it to something local in your hosts file? You only need to configure the plugin with sites that require NTLM, the rest should work without any extra config.

If test-url.com is a valid site, it should still work of course, and one of the lines in the log draw my attention. Created agent for client 127.0.0.1:50363 to target http://test-url.com.com:80/ Could be just an issue with the logging, but might be a potential bug.

ctan66 commented 3 years ago

The domain "test-url.com" is just aliasing name. In IIS of authentication providers, already enabled the "NTLM". However, I still running the same issue with the same error "Error: ESOCKETTIMEDOUT"

I found this time the error log is a different message as shown below. In my machine got to set the Environment variables so-called "NODE_EXTRA_CA_CERTS" and the value is "C:\certs\ca.cer". Did anything go wrong?

p/s: I follow your articles https://github.com/bjowes/cypress-ntlm-auth/issues/112 to configure the CA cert.

cypress:plugin:ntlm-auth Request to https://test-url.com:443/ in registered NTLM Hosts +1ms
cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:56681 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:56684 due to socket.close +55s cypress:plugin:ntlm-auth PROXY_TO_SERVER_REQUEST_ERROR on /: { Error: unable to verify the first certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1177:34) at TLSSocket.emit (events.js:193:13) at TLSSocket._finishInit (_tls_wrap.js:668:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' } Destroying client socket. +15s

===============================================================================

bjowes commented 3 years ago

It seems you just tried to access the site using https instead, therefore you triggered another error. You have set the right environment variable, but it is possible that the file content is incorrect. Please see slide 38 in my presentation https://docs.google.com/presentation/d/1GOuxxnsRQF8g7-xmYG4gYz59_BXBu4fKNgCmOJOAj4c/edit?usp=sharing for details about how to extract the corporate CA cert in the correct format.

ctan66 commented 3 years ago

Thanks a lot... after obtained the correct corporate CA cert, the ntlm plugin work flawless.