python-websockets / websockets

Library for building WebSocket servers and clients in Python
https://websockets.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
5.07k stars 506 forks source link

WebSocket connection failed #1410

Closed VerifyBot closed 8 months ago

VerifyBot commented 8 months ago

After testing my websockets app locally, I have deployed my web app to firebase hosting where it is available through https://someurl.web.app. Sadly the websocket does not seem to connect as I get the following error in the devtools console: image

Note that this is an ngrok server, which works, as can be seen below: image

I have not found anything related to this in the docs, issues or online.

Thank you 🙏

aaugustin commented 8 months ago

That might be https://stackoverflow.com/questions/22644392/chrome-websockets-cors-policy

You should enable debug logs on the server too (that's explained in the docs). Then you can see if:

  1. the browser refuses to make the connection --> this has nothing to do with websockets; see the link I provided above for potential causes
  2. websockets refuses to take the connection --> the logs should tell you what's happening.
VerifyBot commented 8 months ago

Thanks, I ended up realizing that a certificate from openssl isn't enough for the browsers, and that I needed to use Let's Encrypt to generate valid cert files.