dotnet / dotnet/dotnet-api-docs
WebSocket: Document how WebSocket enters Aborted, what states are allowed pre-conditions for calling CloseAsync and CloseOutputAsync, and which exception is thrown if state pre-condition is violated
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Describe the issue or suggestion
Document (on relevant methods, e.g. SendAsync, ReceiveAsync, etc.) how a WebSocket can enter a WebSocketState.Aborted state.
Relatedly (Aborted is not an allowed state for CloseAsync), document which WebSocketState values are allowed pre-conditions when calling CloseAsync and CloseOutputAsync,
As an example of the motivation for this request, I received an error:
```
The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived, CloseSent'
```
when calling CloseAsync (I believe another WebSocket method was cancelled by a CancellationToken, which put it into Aborted state).
CloseAsync (via WebSocketStateHelper) throws a WebSocketException if the pre-condition state is invalid. This needs to be documented as a possible exception anywhere it can be thrown (e.g. CloseAsync, CloseOutputAsync, etc.). Only OperationCanceledException is currently listed.
Contributor guide
Assessment
This issue has not been assessed yet.