-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and serversbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
We get quite some Unobserved Task Exceptions in SignalR when using streaming from client to server.
TaskScheduler.UnobservedTaskException += (sender, eventArgs) =>
{
Log.Error(eventArgs.Exception ?? new Exception(), "Unobserved task exception in sender {Sender}", sender?.ToString());
};
[15:22:16.320 ERR] Unobserved task exception in sender System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.Threading.Tasks.VoidTaskResult,Microsoft.AspNetCore.SignalR.Client.HubConnection+<CommonStreaming>d__67]
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (The 'CommonStreaming' method cannot be called if the connection is not active)
---> System.InvalidOperationException: The 'CommonStreaming' method cannot be called if the connection is not active
at Microsoft.AspNetCore.SignalR.Client.HubConnection.ReconnectingConnectionState.WaitForActiveConnectionAsync(String methodName, CancellationToken token, String memberName, String filePath, Int32 lineNumber)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.SendWithLock(ConnectionState expectedConnectionState, HubMessage message, CancellationToken cancellationToken, String callerName)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.CommonStreaming(ConnectionState connectionState, String streamId, Func`1 createAndConsumeStream)
--- End of inner exception stack trace ---
How we set-up streaming:
await connection.StartAsync(cancellationTokenSource.Token);
await connection.SendAsync("ObservationsStream", observationsChannel.Reader, cancellationTokenSource.Token);
Expected Behavior
No Unobserved Task Exceptions. This pollutes our log.
Steps To Reproduce
This typically happens with SignalR on unstable connections, where there are TCP/IP time-outs.
Exceptions (if any)
No response
.NET Version
6.0.400
Anything else?
SignalR.Client 6.0.8
Metadata
Metadata
Assignees
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and serversbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.