sta / sta/websocket-sharp

Socket closure when sending twice null binary data from chrome

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

Nobody has claimed this yet.

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

Description

During some test with Dark Web Socket Terminal (and Chrome) I found out that if I send an empty binary frame twice the client requires a closure.

You can double check this also with your Echo example.

I solved removing compressing bit if payload length is zero.
So in WebSocketFrame internal costructor

internal WebSocketFrame (
  Fin fin, Opcode opcode, PayloadData payloadData, bool compressed, bool mask)
{
  _fin = fin;
  var len = payloadData.Length;
  _rsv1 = opcode.IsData () && compressed && len > 0 ? Rsv.On : Rsv.Off;
  //...

In your opinion, is it correct? Is it a bug of Chrome?

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.

Research direction

Start in the WebSocketFrame internal constructor shown in the issue and reproduce the problem with Chrome and the Echo example by sending an empty binary frame twice. Inspect how the compression bit is set for a zero-length payload; done means determining whether that behavior explains the closure and verifying the result against the reported reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.