-
Notifications
You must be signed in to change notification settings - Fork 10
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
Protocol "https:" not supported. Expected "http:" #225
Comments
I have not seen this before. Can you please share your test code? Are you
using the latest version? Any corporate proxy in use?
mån 26 dec. 2022 kl. 12:22 skrev Matebo ***@***.***>:
I sometimes get this error causing test execution to stop. Any suggestions?
Running: 15-Classifications.cy.js (15 of 34)
15-Classification.spec
node:_http_client:164
throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
^
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new NodeError (node:internal/errors:372:5)
at new ClientRequest (node:_http_client:164:11)
at Object.request (node:https:353:10)
at makeProxyToServerRequest ***@***.***/http-mitm-proxy/lib/proxy.js:837:38)
at ***@***.***/http-mitm-proxy/lib/proxy.js:830:16
at wrapper (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:271:20)
at eachOfArrayLike (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:490:13)
at eachOf (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:626:16)
at awaitable (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:211:32)
at Object.eachLimit (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:2691:16)
at Object.awaitable (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:211:32)
at Proxy._onRequestHeaders ***@***.***/http-mitm-proxy/lib/proxy.js:972:9)
at ***@***.***/http-mitm-proxy/lib/proxy.js:826:19
at wrapper (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:271:20)
at iteratorCallback (/usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:501:17)
at /usr/local/lib/node_modules/cypress-ntlm-auth/node_modules/async/dist/async.js:327:20 {
code: 'ERR_INVALID_PROTOCOL'
}
—
Reply to this email directly, view it on GitHub
<#225>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCHR3GSPSBZFFN2BUFM5Y3WPF5W7ANCNFSM6AAAAAATJSTWXA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
/Björn W
Skickat från min iPhone
|
I updated cypress to the latest version (12.2.0) and the issue did not reoccur yet since then. |
Still an issue for me
|
Is this a sporadic error or does it occur on every execution at the same point? |
This is a sporadic error |
Maybe this is already clear to you, but the root cause if the issue is that
an https request is attempted through a (presumed) http connection.
The proxy in the plugin keeps track of outgoing requests and sets the
appropriate protocol.
One possibility that has caused some issues in the past is the config API.
The proxy exposes a proxy endpoint and a config API endpoint, and the
config API is called by Cypress when you are changing the NTLM
configuration. The traffic to the config API is always http. If for some
reason https traffic is sent to the config API endpoint, it would likely
result in the observed error.
Is your test case using lots of ports, maybe randomly set? Could it occur
that they collide with the proxy ports?
The proxy ports are picked from free ports on the machine on each launch so
they will vary over time.
To see what ports are used in a specific test run, you can observe them in
the Cypress UI. Go to settings, scroll down to the "env" section of the
resolved configuration. The two endpoints are specified by `NTLM_AUTH_API`
and `NTLM_AUTH_PROXY`.
When running Cypress without UI (cypress run), you would need to enable
Debug logging of the plugin to observe the ports used.
…On Mon, Jan 16, 2023 at 9:59 AM Matebo ***@***.***> wrote:
This is a sporadic error
—
Reply to this email directly, view it on GitHub
<#225 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCHR3H7SMMUDYZIF3I2B3DWSUEYVANCNFSM6AAAAAATJSTWXA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
It just occurred again with debug logging on. So should I suspect that port 54570 is already in use on the Jenkins node that is executing the tests?
|
Thanks for following through on this and providing the debug log! I really needed it to find this edge case. Apparently the browser may sometimes reuse the same outgoing sockets when connecting to a new target on a different protocol. There was some traffic in the log to an http host, and some to the authenticated https host. When the same socket was used for these two connections, the ntlm-proxy tried to pass on the traffic, but the agent type was not compatible with the target. I am working on a patch for this. |
Published version 4.1.2 which should fix this. Please try it out and report back. As a side note, I noticed multiple calls to cy.ntlm from the logs, which seemed to add the same host. Generally you should only need to call this once per test. If you really need to change the actual user account for a specific target during a test, you would also need to call cy.ntlmReset to remove existing connections. |
Thanks for the quick fix. It seems to work well until now. I'm using cy.request to configure some things on other machines before and while running the tests, without the intention of using windows authentication. |
Glad to hear it!
ons 8 mars 2023 kl. 10:41 skrev Matebo ***@***.***>:
Thanks for the quick fix. It seems to work well until now.
I'm using cy.request to configure some things on other machines before and
while running the tests, without the intention of using windows
authentication.
—
Reply to this email directly, view it on GitHub
<#225 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCHR3A37D6IOBKPJIJRCV3W3BH3BANCNFSM6AAAAAATJSTWXA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
--
/Björn W
Skickat från min iPhone
|
The issue occurred again with cypress-ntlm-auth version 4.1.2. I had turned off debug logging, so I don't have them right now. I turned debug logging back on so that I can provide them to you next time. |
That's too bad. Reopening the issue ans waiting for logs. |
It occurred again yesterday. Logs
|
Thanks for the logs. I've made some initial investigations but need to continue. Can you estimate for how long cypress with plugin had been running when this occurred? |
The job takes 30-40 minutes and runs once every day. |
Ok, finally had some time to dig deeper into this. The only likely candidate I have found is that a call to the config API is done on a HTTPS connection (which it doesn't support), and later the same connection is reused to call another site. I have created a beta version that implements a check for config API calls to ensure they are on HTTP before taking any actions on the connection. You can try the beta by installing [email protected] Generally the config API would never be called on a HTTPS connection if only the cy.ntlm, cy.ntlmSso, cy.ntlmReset commands are used. For custom requests to config API, (using cy.request or similar) - all bets are off, the client needs to ensure they use HTTP only. |
Any update on this, did you try out the beta? |
Sorry not yet, my co-workers are picking it up and they are currently doing a major update of our software. I will keep you up to date |
I sometimes get this error causing test execution to stop.
It does not always occur, and sometimes occurs on different tests.
Versions:
"cypress": "^11.2.0",
"cypress-ntlm-auth": "^4.1.1",
Any suggestions?
The text was updated successfully, but these errors were encountered: