-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Actual Behavior
- Lets me close a disposed socked which causes an exception
The service threw an unhandled exception, System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.WebSockets.ClientWebSocket'.
at System.Net.WebSockets.ClientWebSocket.ThrowIfNotConnected()
at System.Net.WebSockets.ClientWebSocket.CloseOutputAsync(WebSocketCloseStatus closeStatus, String statusDescription, CancellationToken cancellationToken)
at Microsoft.Azure.Relay.WebSocketStream.<OnShutdownAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Relay.HybridConnectionStream.<ShutdownAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
- The problem is very similar to a singalIR issues C# Client may try to close a disposed WebSocket aspnet/SignalR#1004
| await this.webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "CloseAsync", linkedCancelSource.Token).ConfigureAwait(false); |
| await this.webSocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Shutdown", linkedCancelSource.Token).ConfigureAwait(false); |
The real issue is that the websockets client throws :(
https://github.com/dotnet/runtime/blob/d6bf13a39c8ccb8fa7815a2f7e4387120a837138/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocket.cs#L226
Expected Behavior
- Do not throw on closing a disposed socket
- or throw? Doesn't seem correct since even singalIR addressed the issue.
Versions
- OS platform and version:
- .NET Version:
- NuGet package version or commit ID:
Reactions are currently unavailable