Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
187
rated 0 times [  191] [ 4]  / answers: 1 / hits: 47720  / 10 Years ago, wed, may 21, 2014, 12:00:00

I am stucked with Firefox. I could not make Websocket work on it. I use Tornado Websocket and I initialized it by code below:



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 Javascript side like this:



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


This code works fine on Chrome, meanwhile I created the cert by myself and run the page under HTTPS. But Firefox keeps saying that:



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


I google it and found too many thoughts but none of'em worked for me :(



Any help will be appreciated.


More From » python

 Answers
4

I solved my problem via ProxyPass. I created a non-secure Websocket server with Tornado and run it on a specific port such as 3232:



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


Then I've written a 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 Websocket client on frontend like this:



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


In this case I can create a connection on a secure connection with https and my port is 81 and my proxypass redirect any Websocket request to locally listened port 3232. It is not a exact solution mostly like a workaround. But it works fine for me.


[#70924] Sunday, May 18, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devlin

Total Points: 474
Total Questions: 113
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
devlin questions
Tue, Apr 27, 21, 00:00, 3 Years ago
Sat, Oct 31, 20, 00:00, 4 Years ago
Fri, Aug 28, 20, 00:00, 4 Years ago
;