Reputation: 55
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 ?
Upvotes: 5
Views: 10676
Reputation: 55
Solved it. for tornadio2 users you have to do that :
add this code to persistent.py(it locate in tornadio2)
def check_origin(self, origin):
return True
Upvotes: -6
Reputation: 22154
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
Upvotes: 21