permessage-deflate incompatible with WKWebView Websocket client and connection getting closed - 1002 status

Open
#666 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
networking

Research direction

Start by running the attached SampleWebSocketServer.zip and SampleWebSocketApp.zip with iPadOS 15 Beta behavior, focusing on permessage-deflate and messages sent in multiple frames. Compare the failing fragmented-message exchange with the working single-frame and IgnoreExtensions cases. Done means identifying the protocol-handling incompatibility and confirming corrected behavior with fragmented compressed messages.

Written by the indexing model from the issue text.

Description

We are having Native swift application which used WKWebView to render app content in JavaScript and HTML. We are using websocket client in JavaScript to connect with WebSocket-Sharp server.

Until the current release iPadOS 14.x versions, WKWebView JS websocket client is sending below extension.
Sec-WebSocket-Extensions: x-webkit-deflate-frame
And the WebSocket-Sharp is not sending back any header and no compression technique is followed between the server and client when any message is being sent.

With the recent release of iPadOS 15 Beta, while establishing handshake WKWebView JS websocket client is sending below extension.
Sec-WebSocket-Extensions: permessage-deflate
And the WebSocket-Sharp server responding with below header in response.
Sec-WebSocket-Extensions: permessage-deflate; client_no_context_takeover; server_no_context_takeover

And when any message is being sent from server (websocket-sharp) to client (iPad OS 15 Beta), we are facing below error at client end and client socket instance is getting closed with 1002 - protocol error.
nw_ws_parse_input_block_invoke [C4:4] inflate returned data error

There is another catch here that only messages which are sent in multiple frames are getting thrown this exception, and if we modify FragmentLength in c# to handle large messages and sending in single frame, it is working fine.

And also I tried IgnoreExtensions, in that case also working fine, but wanted to know why this is failing with permessage-deflate extension ?

Attached the sample native swift application and websocket-sharp server code.
SampleWebSocketServer.zip
SampleWebSocketApp.zip

Can anyone help me why this is getting failed with messages that are being sent in multiple frames, when permessage-deflate extension is sent from client ?

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sta/websocket-sharp

All issues in sta/websocket-sharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.