Bad handling of sending stream makes lib not RFC compatible and KeepClean useless in some cases.

Open
#760 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in WebSocket.cs at the private send(Opcode opcode, Stream sourceStream) method and compare its locking and fragmented-send behavior with RFC 6455 section 5.5. Reproduce a slow or large stream transfer with KeepClean enabled, then verify that control-frame handling is no longer stalled during the transfer and that the connection remains usable.

Written by the indexing model from the issue text.

Description

I do not know if this is required, but for WebSocket.cs call:
private bool send (Opcode opcode, Stream sourceStream)
send lock is put prematurely. This will violate RFC behaviour described in: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5

Also makes option KeepClean switch useless when sending larger data or network stream is getting slow. Ping request is stalled until fragmented transfer finish transfer, but should be sent in between data fragments as RFC allows it. Because of this and flawed internal logic, connection can be closed due to Ping not responding with KeepClean set to true.

Current workaround is to implement custom Ping/Pong logic.

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.