I am currently developing a WebSocket server in Python but I am not able to calculate the Sec-WebSocket-Accept apparently, which is not very difficult normally.
Here is my function to calculate this (written in Python) :
def get_accept_websocket_key(self, key):
magic_string = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
key += magic_string
return base64.b64encode(hashlib.sha1(key).hexdigest())
All my results seems to be good but I always have in the javascript console :
Error during WebSocket handshake: Sec-WebSocket-Accept mismatch
Have you any solution?
Thank you.
The working example.
Lookup at code with “Sec-WebSocket-Protocol”