Feature request: User-oriented WebSocket server and client
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
The .NET BCL includes a low-end, raw ClientWebSocket class dealing at the frame level with the protocol. You have to pass it `ArraySegment`, you have to assemble frames into messages, manage, pipeline and pump both sides of the connection. Many platforms have a blessed WebSocket client (and sometimes server) that abstracts over receiving frames and pipelining ongoing requests. For example, the client inside the HTML5 standard is able to work on a more user-oriented layer, with events for messages which pieces together frames for you.
[As David points out](https://twitter.com/davidfowl/status/1195070771007086593), implementing this in a correct, speedy and secure way is hard. It has been done today in ASP.NET Core and exists as part of the implementation of SignalR. It would be a good opportunity to provide a well-implemented WebSocket client and server that is as robust, and that can be used out of the box, for the times where using WebSocket directly is required. It seems to me that maybe it could be possible to layer this such that the SignalR implementation would be able to use the WebSocket client/server as is, and to mirror previous efforts to extract publicly reusable components from the internal infrastructure.
There are ways in which implementing a WebSocket server (especially) could require tuning, like for how many frames to allow buffering - this is the case for the WebSocket implementation as part of SignalR or the HTTP or binary protocols provided by Kestrel just as well, where secure defaults have been set, judgments have been made and some knobs provided.
Contributor guide
Assessment
This issue has not been assessed yet.