0

My Python script has created a WebSocket and is able to connect to the server using that WebSocket. The server sends a response on the WebSocket that I've created, but the WebSocket module seems to be unable to decode it.

This is the error i'm seeing:

-----------------------
Traceback (most recent call last):
  File "test_file.py", line 307, in <module>
    result = ws.recv()
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 293, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 310, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 334, in recv_data_frame
    return self.cont_frame.extract(frame)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_abnf.py", line 428, in extract
    "cannot decode: " + repr(frame.data))
websocket._exceptions.WebSocketPayloadException: cannot decode: '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x9dUmk\xeb6\x14\xfe+\xc1\x1f\xc7ug\'v\x1c\x17\xc6\xb8t\xa5\x0b\xac\xbdwm\x06\x83\xb9\x08Y>N\xb5kK\x8e$\'\xcdJ\xff\xfbt$;vac0\x87\x18\xe9\xbc<\xe7\xfd\xf8m\x11\x80RR1YAp\xbd\x88>-\x82\x16\xb4\xa6{\xbc\x05\x9f\xf7 \xccW%_\xcf7\xb2m{\xc1\x195\\\x8a\xc0JqMz\'

This is the piece of code where i'm initiating a websocket and listening to the server resopnse:

ws = websocket.create_connection(full_url, header = header_set)
result = ws.recv()
print result

It's failing in the ws.recv() line. Any ideas?

Muhammad Umair
  • 1,664
  • 2
  • 20
  • 28
Randomly Named User
  • 1,889
  • 7
  • 27
  • 47

1 Answers1

0

This seems to be a known issue with websocket-client version 0.16. Try updating the package to 0.34, or higher, to see if that resolves the issue.

Apparently, this is because websocket-client changed how they handled frame validation in a version after 0.16 (not exactly sure what version though, so try updating to latest).

Supporting link: https://github.com/dpallot/simple-websocket-server/issues/24

sadmicrowave
  • 39,964
  • 34
  • 108
  • 180