The header of a frame cannot be read from the stream
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
This WebSocketException "The header of a frame cannot be read from the stream" is always thrown when closing the web socket client.
I have an example of a websocket client sending and receiving the same message from the backend.
WebSocketClient
using (var ws = new WebSocket ("wss://localhost:44398/ws"))
{
ws.OnMessage += (sender, e) =>
Console.WriteLine ("Received Message: " + e.Data);
ws.Connect ();
ws.Send ("Test Message");
Console.ReadKey();
}
Backend
It is an asp.net core web application which only receive the request from the WebSocketClient and it answers back with the same message.
It returns the message as expected, but then after entered any key to continue with the execution it fails and throws the above exception at the time of closing the web socket client.
Here is the the code if you would like to take a look.
https://github.com/juanrivera2306/WebSocketSample
There is a README.txt file with the instructions to run the example.
I really appreciate any help you can provide.
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
Start with the linked WebSocketSample repository and its README.txt, then reproduce the failure from WebSocketClient when the using block closes after Console.ReadKey(). Compare that close path with the backend's echoed-message behavior; done means the sample can close the client without the reported WebSocketException.
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
- Mostly clear
- Newbie friendliness
- 25/100