Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(tornadio2) failed: Error during WebSocket handshake: Unexpected response code: 403

when I run my code on my pc and try to connect socket with my index.html on localhost no problem but when I try to run my code on server and try to connect socket with index.html(it locate on my pc) I get :

Router <tornadio2.session.ConnectionInfo object at 0x7f7bfc5fac10>
INFO:tornado.access:200 GET /socket.io/1/
DEBUG:root:Initializing websocket handler.
WARNING:tornado.access:403 GET /socket.io/1/websocket/c0532cea9001408c50a9c854f4bce5d8

and after that it switch protocal to xhr-polling but I want to use websocket.

INFO:tornado.access:200 GET /socket.io/1/xhr-polling/62f9b31662c984201685a830c764765e
DEBUG:root:Initializing xhr-polling transport.
DEBUG:root:>>> 1::/socket
DEBUG:root:<<< 1::/socket
DEBUG:root:<<< 3::/socket:connected!

what can I do to fix that problem ?

like image 762
Ozan Avatar asked Aug 07 '14 07:08

Ozan


1 Answers

The html must be loaded from the same server as the websocket unless you override check_origin to allow cross-origin access: http://www.tornadoweb.org/en/stable/websocket.html#tornado.websocket.WebSocketHandler.check_origin

like image 156
Ben Darnell Avatar answered Nov 03 '22 20:11

Ben Darnell