title: Data encoding in new protocol handshake hybi-10
body: <p>I'm using a WebSocket for python and JavaScriptand until now the handshake protocol for Google Chrome was <a href="https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-00#page-7" rel="nofollow noreferrer">draft hybi-00</a>. I guess Google Chrome changed the protocol to <a href="https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-10" rel="nofollow noreferrer">draft hybi-10</a> recently.</p>
  <p>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:</p>
  <pre><code>viz.ws = new WebSocket(&quot;ws://127.0.0.1:5500&quot;);
              
  viz.ws.onopen = function() {
      viz.ws.send(&quot;TEST\n&quot;);
  };
  </code></pre>
  <p>My server in Python receives this data. However, it is encoded somehow and I can't get the simple text <code>&quot;TEST\n&quot;</code> I sent:</p>
  <pre><code>    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')
  </code></pre>
  <p>The prints return this:</p>
  <pre><code>üàÍu┬¯é0æ║▄
  u0
  </code></pre>
  <p>And they're always different, but the sent text is always <code>TEST\n</code>.</p>
  <p>Also, the server receives this data, but the client isn't receiving any data sent from the server.</p>
  <p>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...</p>