Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Websocket problem with latest Firefox versions #8

Merged

Conversation

softworkz
Copy link
Contributor

The latest Firefox versions (>=37) are using permessage compression.
The current implementation of permessage compression in websocket-sharp
is incorrect because it creates a new DeflateStream object for every
message, but this is only allowed, if client_no_context_takeover or
server_no_context_takeover has been agreed during the handshake.
Otherwise the DeflateStream object would need to be persisted and reused
for each connection, in order to implement the LZ77 sliding window.

I tried to copy over some stuff from websocket-sharp, to include
client_no_context_takeover and server_no_context_takeover, but that does
not have any effect on the Firefox behaviour. According to the spec, the
server may just acknowledge the extensions requested by the client, but
may not add options (like client_no_context_takeover). As a consequence,
this didn't solve the problem.

The final solution would of course be to change the code to reuse the
DeflateStream objects, but it hasn't even been done in webbsocket-sharp.
Instead websocket-sharp has introduced an IgnoreExtensions property
which effectively disables lines 163-165 in WebSocket.cs. I have
commented these out in our code as a quick fix. As a result permessage
compression is simply disabled.

This change finally made Emby-Websockets on Firefox clients work again!

The latest Firefox versions (>=37) are using permessage compression.
The current implementation of permessage compression in websocket-sharp
is incorrect because it creates a new DeflateStream object for every
message, but this is only allowed, if client_no_context_takeover or
server_no_context_takeover has been agreed during the handshake.
Otherwise the DeflateStream object would need to be persisted and reused
for each connection, in order to implement the LZ77 sliding window.

I tried to copy over some stuff from websocket-sharp, to include
client_no_context_takeover and server_no_context_takeover, but that does
not have any effect on the Firefox behaviour. According to the spec, the
server may just acknowledge the extensions requested by the client, but
may not add options (like client_no_context_takeover). As a consequence,
this didn't solve the problem.

The final solution would of course be to change the code to reuse the
DeflateStream objects, but it hasn't even been done in webbsocket-sharp.
Instead websocket-sharp has introduced an IgnoreExtensions property
which effectively disables lines 163-165 in WebSocket.cs. I have
commented these out in our code as a quick fix. As a result permessage
compression is simply disabled.

This change finally made Emby-Websockets on Firefox clients work again!
LukePulverenti added a commit that referenced this pull request Sep 25, 2015
Fixed Websocket problem with latest Firefox versions
@LukePulverenti LukePulverenti merged commit c9f849e into MediaBrowser:master Sep 25, 2015
@LukePulverenti
Copy link
Member

Excellent, thanks! Really glad to see this one fixed.

@softworkz
Copy link
Contributor Author

Wow, that was a quick merge :-)
PS: Closes MediaBrowser/Emby#1194

@softworkz softworkz deleted the WebSocketCompressionFix branch September 25, 2015 04:37
@softworkz
Copy link
Contributor Author

Actually this also closes MediaBrowser/Emby#1193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants