Cannot establish a secure connection to Websocket in Firefox.

I am stuck in Firefox. I could not get Websocket to work on this. I am using Tornado Websocket and I initialized it with the following code:

app = Application([(r'/mypath/ws', WSHandler)]) http_server = HTTPServer(app, ssl_options={ "certfile": "~/certs/websocket.crt", "keyfile": "~/certs/websocket.key" }) http_server.listen("443") 

And I initialized it on the Javascript side as follows:

 var WS = new WebSocket("wss://websocket.localhost/mypath/ws"); 

This code works fine in Chrome, meanwhile I created the certificate myself and launched the page under HTTPS. But Firefox continues to say that:

 Firefox can't establish a connection to the server at wss://websocket.localhost/mypath/ws. 

I google and found too many thoughts, but none of them worked for me :(

Any help would be appreciated.

+4
javascript python firefox tornado websocket
source share
5 answers

I solved my problem through ProxyPass. I created an insecure Websocket server with Tornado and ran it on a specific port, such as 3232:

 app = Application([(r'/ws/', WSHandler)]) ws_server = HTTPServer(app) ws_server.listen("3232") 

Then I wrote proxypass in my Apache conf and use mod_proxy_wstunnel:

 ProxyPass /ws/ ws://127.0.0.1:3232/ws/ ProxyPassReverse /ws/ ws://127.0.0.1:3232/ws/ 

And I create the Websocket client on the frontend as follows:

 var WS = new WebSocket("wss://websocket.localhost:81/ws/") 

In this case, I can create a connection in a secure connection with https, and my port is 81, and my proxypass redirects any Websocket request to the locally listening port 3232. This is not an exact solution, mainly as a workaround. But it works great for me.

+1
source share

If it is a self-signed certificate, browsers will not display a dialog to accept the certificate if it is used only in a web schedule. You must first visit a regular page on the same server to see and accept the certificate warning, and then you can create a secure website.

+2
source share

I solved this problem by adding a certificate exception to Firefox advanced settings.

0
source share

Try opening this https: //websocket.localhost/mypath/ws URL in firefox and accept the certificate first.

0
source share

I pulled my hair for a while. I received all kinds of critical error messages depending on different web browsers, and it all sounded like it was something like certificate exceptions. I have already made exceptions in Firefox and Chrome,

It turned out that I had a typo in my subprotocol line in my Javascript!

Adjusting the sub-protocol line made everything better. Additional information on WebSockets and the use of sub-protocol (s): https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

0
source share

All Articles