-
Notifications
You must be signed in to change notification settings - Fork 5k
Add WebSocketStream #114363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WebSocketStream #114363
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/ncl |
if (WebSocket.State is WebSocketState.Open) | ||
{ | ||
// There's no synchronous close, so we're forced to do sync-over-async. | ||
WebSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, null, CancellationToken.None).GetAwaiter().GetResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this cause deadlocks in UI contexts such as WPF and Windows Forms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as long as everything within CloseOutputAsync uses ConfigureAwait(false)
{ | ||
if (WebSocket.State is WebSocketState.Open) | ||
{ | ||
await WebSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, null, CancellationToken.None).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it reasonable to use CancellationToken.None
here? Since we're disposing the websocket if the remote party fails to respond to the Close request and we don't have a keep alive set, we will basically hang here.
Would it not be better if we have some timeout for the close to complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The close timeout is one of the open questions at the moment. The full list is in #111217 (comment) -- we'd appreciate your thoughts on it as well 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From an API standpoint I would prefer if the close timeout can be specified in WebSocketCreationOptions
much like the KeepAliveTimeout
. Doing so eliminates the need for the consumers of the WebSocket
to know about it. I would even go further than this, making the CloseTimeout
have a meaningful value by default.
Closing until design concerns are addressed |
Closes #111217