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

Websocket with wrong protocol on HTTPS Development ENV #8075

Closed
wviveiro opened this issue Dec 5, 2019 · 4 comments · Fixed by #8079
Closed

Websocket with wrong protocol on HTTPS Development ENV #8075

wviveiro opened this issue Dec 5, 2019 · 4 comments · Fixed by #8079

Comments

@wviveiro
Copy link

wviveiro commented Dec 5, 2019

Describe the bug

When forcing HTTPS=true on NPM start the error "WebSocket connection to 'ws://localhost:3000/sockjs-node' failed: Connection closed before receiving a handshake response"

I couldn't find a solution for this without ejecting the code.

Did you try recovering your dependencies?

It is a brand new npx create-react-app app. The problem is not present in other project running react-scripts 3.0.1

Which terms did you search for in User Guide?

Searched for websocket, force wss
On google I searched for create-react-app websocket, create-react-app force wss, create-react-app https

Environment

System:
OS: macOS 10.15
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.5.1 - ~/.yarn/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Browsers:
Chrome: 78.0.3904.108
Firefox: 62.0
Safari: 13.0.2
npmPackages:
react: ^16.12.0 => 16.12.0
react-dom: ^16.12.0 => 16.12.0
react-scripts: 3.3.0 => 3.3.0
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. npx create-react-app app
  2. cd app
  3. npm i cross-env
  4. replace "start": " react-scripts start" to "start": "cross-env HTTPS=true react-scripts start"
  5. npm start
  6. Open https://localhost:3000
  7. script still tries to open websocket on WS protocol.

Expected behavior

Script opens websocket on WSS protocol

Actual behavior

Script still tries to open websocket on WS protocol.

image

Reproducible demo

@dimaqq
Copy link

dimaqq commented Dec 5, 2019

I think I've hit this or related to it too, my setup:

  • react-scripts 3.3.0
  • react-dev-utils 10.0.0
  • yarn start on localhost:3000 (that works)
  • actually loading the site over https://.ngrok.io (I need it for trusted redirect dance)

And I get SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

The same scenario works with following versions:

  • react-scripts 3.2.0
  • react-dev-utils 9.1.0

@mikecaulley
Copy link
Contributor

Can you try #8079 ?

It should fix your issue.

@driek-vhees
Copy link

driek-vhees commented Dec 5, 2019

@mikecaulley Ran into same issue and like to confirm that patch in #8079 seems to work here 👍
(did patch it in manually)

├─ react-dev-utils@10.0.0
├─ react-scripts@3.3.0
├─ react@16.12.0

(trimmed for brevity)

@wviveiro
Copy link
Author

wviveiro commented Dec 5, 2019

Yeap, worked fine, thanks !

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

Successfully merging a pull request may close this issue.

4 participants