crazydiv
crazydiv

Reputation: 842

Websocket handshake status 426

I have a tornado server listening at port 9000, but when I try to create a connection from websocket-client, I am getting the following error.

 Traceback (most recent call last):
      File "XXX", line 879, in custom_func
        ws = create_connection("ws://127.0.0.1:9000/")
      File "/usr/local/lib/python2.7/dist-packages/websocket.py", line 110, in create_connection
        websock.connect(url, **options)
      File "/usr/local/lib/python2.7/dist-packages/websocket.py", line 210, in connect
        self._handshake(hostname, port, resource, **options)
      File "/usr/local/lib/python2.7/dist-packages/websocket.py", line 246, in _handshake
        raise WebSocketException("Handshake Status %d" % status)

WebSocketException: Handshake Status 426

In tornado, 426 means Upgrade required. I've already upgraded my client but I still get the same error. Here is my pip freeze:

tornado==3.1
websocket-client==0.4

I am using the following import:

from websocket import create_connection

Upvotes: 1

Views: 2893

Answers (1)

daharon
daharon

Reputation: 2010

Here you can see that websocket-client implements Websocket protocol draft 76.
Also, notice that 0.4 is three years old. 0.12 is the latest version.

This is where you are getting the 426 from.

You need to override the WebSocketHandler.allow_draft76 method.

Upvotes: 2

Related Questions