Websocket-sharp-server: Ping sent delayed during heavy data transfer
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
When stress testing websocket-sharp-server with intensive data transfer (mostly from server to client), I have noticed that Ping (from server to the client), however executing "internal bool Ping (byte[] frameAsBytes, TimeSpan timeout)" and its "sendBytes(frameAsBytes)", does not actually sent the Ping for very long time. The time is so long that the Sweep terminates the socket soon afterwards.
My test is using short binary (14 bytes) messages (x 1000) passed via "public void Send (byte[] data)". Both "internal bool Ping(byte[] frameAsBytes, TimeSpan timeout)" and "private bool send(Opcode opcode, Stream stream)" finish in sendBytes(), which in turn writes to the same "_stream". If the stream is containing large number of data, then the appended "Ping frame" will wait until the buffer reaches it. In the meantime the Sweep fails. This would mean that the websocket cannot be used in heavy data usage, or I will have to wait on every (every some) call to Send, for the _stream to be empty. This to make sure the upcoming "Ping frame" has priority.
Is my observation correct? How to control the flow the best way, not to disturb the websocket protocol, and not to abuse the _stream?
I have code base marked as 1.0.2.* checkout 91 days ago.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace Send(byte[] data), Ping(byte[] frameAsBytes, TimeSpan timeout), send(Opcode opcode, Stream stream), and sendBytes(frameAsBytes), focusing on their shared _stream and the Sweep behavior. Reproduce the delayed-ping case with many short binary messages and determine whether the issue is confirmed and what flow-control behavior is required for completion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100