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

Cypress running on HTTP protocol but Chrome tries to redirect to HTTPS (HSTS issue?) #2996

Closed
techieshark opened this issue Dec 27, 2018 · 4 comments

Comments

@techieshark
Copy link

Current behavior:

yarn cypress open

Opens Cypress, and I can run a test initially 👍.
But if I close the cypress browser, then restart, Chrome tries to redirect to HTTPS protocol (rather than HTTP where cypress is running).

image

(In text:)

This site can’t be reached localhost unexpectedly closed the connection.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_CLOSED

Logs show HTTP 200 codes, then later HTTP 500 error codes:

GET /__/ 200 32.948 ms - -
GET /__cypress/runner/cypress_runner.css 200 47.385 ms - -
GET /__cypress/runner/cypress_runner.js 200 407.653 ms - -
GET /__cypress/iframes/integration/test_widget.js 200 14.653 ms - 729
GET /__cypress/tests?p=cypress/integration/test_widget.js-978 200 1284.204 ms - -
GET /__cypress/tests?p=cypress/support/index.js-661 200 1523.106 ms - -
GET /__/ 200 3.119 ms - -
GET /__cypress/runner/cypress_runner.css 200 44.226 ms - -
GET /__cypress/runner/cypress_runner.js 200 312.244 ms - -
GET /__cypress/iframes/integration/test_widget.js 200 3.701 ms - 729
GET /__cypress/tests?p=cypress/support/index.js-502 200 3.365 ms - -
GET /__cypress/tests?p=cypress/integration/test_widget.js-868 200 3.386 ms - -
GET / 200 5.387 ms - -
GET /static/js/bundle.js 200 46.019 ms - -
GET /static/js/main.chunk.js 200 71.848 ms - -
GET /static/js/0.chunk.js 200 404.729 ms - -
GET /sockjs-node/info?t=1545897520428 200 6.486 ms - -
HEAD / 500 40.350 ms - -
HEAD / 500 42.385 ms - -
HEAD / 500 45.004 ms - -
GET / 200 2.000 ms - -
GET /static/js/0.chunk.js 304 23.613 ms - -
GET /static/js/main.chunk.js 304 22.061 ms - -
GET /static/js/bundle.js 304 20.583 ms - -
GET /sockjs-node/info?t=1545897530884 200 8.911 ms - -
The automation client disconnected. Cannot continue running tests.
HEAD / 500 44.353 ms - -
HEAD / 500 46.006 ms - -
HEAD / 500 47.517 ms - -
^C

I tried this with both Chrome and Electron.

Behavior in Electron was similar but I actually got the error messages below half-way through my two tests (I suspect HSTS was set after first test).

Cypress errored attempting to make an http request to this url:

https://localhost:3000/

The error was:

write EPROTO 140735814595456:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../../vendor/node/deps/openssl/openssl/ssl/s23_clnt.c:797:

The stack trace was:

Error: write EPROTO 140735814595456:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../../vendor/node/deps/openssl/openssl/ssl/s23_clnt.c:797:

at exports._errnoException (util.js:1024:11)
at WriteWrap.afterWrite (net.js:851:14)

Desired behavior:

Either:
a) Chrome should always navigate to HTTP protocol / port, or
b) always HTTPS,

but not HTTP initially then HTTPS later.

I suspect that the issue is related to HSTS. Below you see that there's an HSTS entry for localhost that forces HTTPS; if I delete that (after every test) chrome no longer attempts to redirect to HTTPS.

image

Steps to reproduce: (app code and test code)

will be forthcoming

Versions

cypress 3.1.4
Mac OS X 10.13.5
Chrome: 71

@jennifer-shehane
Copy link
Member

Hi, do you know if this also happens on previous versions of Cypress? Did this happen on upgrade or is this your first time running Cypress?

@techieshark
Copy link
Author

Hi Jennifer, this was my first time running Cypress. I just tried installing 3.1.0 but no luck there either.

@jennifer-shehane
Copy link
Member

What is your test code? What are you passing to cy.visit()? Do you use a baseUrl setting? How do you set that if so?

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jan 2, 2019
@techieshark
Copy link
Author

Previously I was starting react app on port 3000 and using nginx to forward HTTPS to it. Not sure if that is related, but...

I've switched to using PORT=4443 HTTPS=true react-scripts start and it seems to work now, so I'll close this issue.

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

2 participants