I'm using a WebSocket for python and JavaScriptand until now the handshake protocol for Google Chrome was draft hybi-00. I guess Google Chrome changed the protocol to draft hybi-10 recently.
So today I updated the handshake code and now the WebSocket is succefully created and opened. On the onopen event in JavaScript, I send a simple text message:
viz.ws = new WebSocket("ws://127.0.0.1:5500");
viz.ws.onopen = function() {
viz.ws.send("TEST\n");
};
My server in Python receives this data. However, it is encoded somehow and I can't get the simple text "TEST\n"
I sent:
def recv_data(self, client, count):
try:
data = client.recv(count)
except:
return False
print data
print data.decode('utf-8','ignore')
return data.decode('utf-8', 'ignore')
The prints return this:
üàÍu┬¯é0æ║▄
u0
And they're always different, but the sent text is always TEST\n
.
Also, the server receives this data, but the client isn't receiving any data sent from the server.
I read that hybi-10 uses binaries... Am I missing a data conversion in that code? I'm sorry, I'm really new to WebSockets and these protocols are messing with my head...