Search Unity

Chrome WebSockets

Discussion in 'Web' started by gfoot, Mar 11, 2015.

  1. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Has anybody had any success using WebSockets from Chrome, in WebGL builds?

    My networking library works well in Firefox now, but when running from Chrome it fails to connect. I've tried two different C#-based libraries on the server side (Alchemy and websocket-sharp), and both reject the connection due to malformed headers, as far as I can tell.

    It looks like Chrome is splitting the handshake across several send() calls, and the server libraries aren't coping with that properly. I'm pretty sure they are at fault, but I thought I'd ask in case anybody has other experience here.
     
  2. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    I debugged this in more detail. Jonas's websocket.jslib specifies an explicit protocol list, but my server code wasn't sending back a Sec-WebSocket-Protocol header in its handshake response, and Chrome didn't like that.

    Removing the explicit protocol list from the request, or making the server reply with a valid protocol, fixes the problem.
     
    DarkPixel likes this.