title: How to read BLOB data from a WebSocket which is not an image
body: <p>I created a WebSocket connection to my webserver to receive some data. However, when I log the event that I receive in the <code>onmessage</code> function, then I cannot see the real content of the data. </p>
  
  <p>When I copy the network connection that my Chrome browser v32 opens as a curl command and run it on my OS console, then everything works fine. So I think that somehow my WebSocket setup must be wrong. The <code>event.data</code> object is an instance of <code>Blob</code>.</p>
  
  <p><strong>Here is my code</strong> (actually CoffeeScript, but easy to understand)<strong>:</strong></p>
  
  <pre><code>socket = new WebSocket "wss://myserverurl/some-endpoint"
  
  socket.onopen = (event) -&gt;
      console.log 'Connection opened (WebSocket)'
  
  socket.onclose = (event) -&gt;
      console.log 'Connection closed (WebSocket)'
      code = event.code
      reason = event.reason
      wasClean = event.wasClean
  
  socket.onmessage = (event) -&gt;
      console.log JSON.stringify event
  </code></pre>
  
  <p>The <code>event</code> that I get:</p>
  
  <pre><code>{
      "ports": [],
      "data": {
          "type": "",
          "size": 594
      },
      ...
      "cancelBubble": false,
      "returnValue": true,
      "srcElement": {
          "binaryType": "blob",
          "extensions": "",
          "protocol": "",
          "onerror": null,
          "bufferedAmount": 0,
          "readyState": 1
      },
      "defaultPrevented": false,
      "timeStamp": 1390578698613,
      "cancelable": false,
      "bubbles": false,
      "eventPhase": 2,
      "currentTarget": {
          "binaryType": "blob",
          "extensions": "",
          "protocol": "",
          "onerror": null,
          "bufferedAmount": 0,
          "readyState": 1
      },
      "target": {
          "binaryType": "blob",
          "extensions": "",
          "protocol": "",
          "onerror": null,
          "bufferedAmount": 0,
          "readyState": 1
      },
      "type": "message"
  }
  </code></pre>