title: Why JS-client doesn't receive binary from server?
body: <p>Server (crystal)</p>
  
  <pre><code>require "http"
  
  module Network
      class WebSocket &lt; HTTP::WebSocketHandler
          HANDLERS = [] of HTTP::Handler
          def initialize (@path : String, &amp;@proc : HTTP::WebSocket, HTTP::Server::Context -&gt; Nil)
              HANDLERS &lt;&lt; self
          end
  
          def self.run (host : String = "::", port : Int32 = 3030)
              puts "Run server on ws://[#{host}]:#{port}"
              HTTP::Server.new(host, port, HANDLERS).listen
          end
      end
  end
  
  Network::WebSocket.new "/" do |socket|
      socket.send("Hello From Binary!".to_slice)
  end
  
  Network::WebSocket.run
  </code></pre>
  
  <p>Client(JavaScript)</p>
  
  <pre><code>ws = new WebSocket("ws://[2a01:4f8:xx:xx::xx]:3030/")
  ws.onmessage = (message) =&gt; {
      console.log(message.data)
  }
  </code></pre>
  
  <blockquote>
    <p>Console.log show me ArrayBuffer(13) with byte length and without any payload.</p>
  </blockquote>
  
  <p>But! Python client (<a href="https://github.com/websocket-client/websocket-client" rel="nofollow noreferrer">https://github.com/websocket-client/websocket-client</a>) works fine.</p>
  
  <pre><code>from websocket import create_connection
  ws = create_connection("ws://[::]:3030")
  print("Receiving...")
  result =  ws.recv()
  print("Received '%s'" % result)
  ws.close()
  </code></pre>
  
  <p>Binary receiving doesn't work in chromium &amp; firefox.</p>