sta / websocket-sharp

A C# implementation of the WebSocket protocol client and server
http://sta.github.io/websocket-sharp
MIT License
5.67k stars 1.65k forks source link

monoPosixHelper error when receiving message with "permessage-deflate" #277

Open arjanwiegel opened 8 years ago

arjanwiegel commented 8 years ago

Contrary to Chrome, Firefox sends its websocket-client messages with the "permessage-deflate" extension, which causes a "monoPosixHelper" helper error in Unity upon reception of the first message. This error closes the connection to the client.

client code: `` socket = new WebSocket("ws://192.168.20.223/get");

socket.onmessage=function(event){console.log("message:");console.log(event);}

socket.send("Hello World"); ``

sta commented 8 years ago

Hello there,

On which OS do you use Unity?

arjanwiegel commented 8 years ago

I use unity 5.3.4 x64 for Windows. I believe that is has to do with the mono frontend that's not 100% compatible with .NET. Simple things like compression are not available. We managed to work around this by de-activating the compression and recompiling the DLL.

sta commented 8 years ago

Simple things like compression are not available.

You are right. Unfortunately, it is not available at least with Unity for Windows.

FYI, you use this library as role of a server? If so, you can ignore extensions, with such as below:

yourServer.AddWebSocketService<YourBehavior> (
  "/YourServicePath",
  () =>
    new YourBehavior () {
      // To ignore the extensions requested from a client.
      IgnoreExtensions = true
    }
);
arjanwiegel commented 8 years ago

Nice! That defeats Hacking into the code nd recompiling crippled dll. 😃