sta / websocket-sharp

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

CompressionMethod.Deflate doesn't work on Mono in Windows #121

Open allaud opened 9 years ago

allaud commented 9 years ago

The thing is that System.IO.DeflateStream is used. And it uses system implementation if gzip (thats why it doesn't work on Windows at least). One good idea is to use SharpZipLib - it is a pure C# implementation of zip. What do you think, @sta ?

System.DllNotFoundException: MonoPosixHelper
  at (wrapper managed-to-native) System.IO.Compression.DeflateStream:CreateZStream (System.IO.Compression.CompressionMode,bool,System.IO.Compression.DeflateStream/UnmanagedReadOrWrite,intptr)
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) [0x00000] in <filename unknown>:0 
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode,bool)
  at WebSocketSharp.Ext.compress (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at WebSocketSharp.Ext.Compress (System.IO.Stream stream, CompressionMethod method) [0x00000] in <filename unknown>:0 
  at WebSocketSharp.WebSocket.send (Opcode opcode, System.IO.Stream stream) [0x00000] in <filename unknown>:0 
UnityEngine.Debug:Log(Object)
sta commented 9 years ago

Hmm,,, unfortunately, that compression extension seems not to be available in Unity for Windows.

One good idea is to use SharpZipLib - it is a pure C# implementation of zip. What do you think,

I guess to use another compression library such as SharpZipLib is a workaround for that error, but i don't plan to use it in websocket-sharp for now.

FREEZX commented 9 years ago

What can i do to fix this issue in windows?

allaud commented 9 years ago

@FREEZX I have a question on SO, maybe you can try something suggested: http://stackoverflow.com/questions/29622743/zip-compression-support-in-unity

Also, our team already solved the problem of data compression. We changed suggested deflate algorithm (which doesn't have good implementation for Unity) with LZMA algo (implementation can be found here: http://www.7-zip.org/sdk.html)

FREEZX commented 9 years ago

@allaud I ended up just disabling compression altogether by setting base.IgnoreExtensions = true; in the constructor of my websocketbehavior object, and it works great.

pmace commented 9 years ago

FYI: this is also a problem with the latest Chrome release and RC3. Previously worked but WebSocketServer now blows up receiving deflated data from our Chrome app.

FREEZX solution base.IgnoreExtensions = true works...for now.

leonardosnt commented 8 years ago

Same here :S