Skip to content
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

v1.26.0 spamming with "OnDisconnectedAsync" error #1988

Open
DevVanilli opened this issue Jul 22, 2024 · 6 comments
Open

v1.26.0 spamming with "OnDisconnectedAsync" error #1988

DevVanilli opened this issue Jul 22, 2024 · 6 comments

Comments

@DevVanilli
Copy link

DevVanilli commented Jul 22, 2024

With a recent version update, the library started spamming with the given error. It happens whenever application is stopped/restarted.

Error when dispatching '"OnDisconnectedAsync"' on hub.
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.
at Autofac.Core.Lifetime.LifetimeScope.ThrowDisposedException()
at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag)
at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.OnDisconnectedAsync(HubConnectionContext connection, Exception exception) at Microsoft.AspNetCore.SignalR.HubConnectionHandler1.HubOnDisconnectedAsync(HubConnectionContext connection, Exception exception)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler1.RunHubAsync(HubConnectionContext connection) at Microsoft.AspNetCore.SignalR.HubConnectionHandler1.OnConnectedAsync(ConnectionContext connection)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.OnConnectedAsync(ConnectionContext connection)
at Microsoft.Azure.SignalR.ServiceConnection.ProcessApplicationTaskAsyncCore(ClientConnectionContext connection)

@vwxyzh
Copy link
Contributor

vwxyzh commented Jul 24, 2024

@vicancy, it looks related with #1960
DefaultHubDispatcher --> HubLifetimeManager<THub>
ServiceLifetimeManager<THub> : ServiceLifetimeManagerBase<THub> : HubLifetimeManager<THub>
ServiceLifetimeManager<THub> --> IServiceConnectionManager<THub>
ServiceConnectionManager<THub> : IDisposable, IServiceConnectionManager<THub>

@DevVanilli
Copy link
Author

DevVanilli commented Jul 25, 2024

Interesting. Supposedly v1.26.0 fixed the problem but for me the problem started with that version (maybe just a coincidence).

@vicancy
Copy link
Member

vicancy commented Jul 26, 2024

Connections were not cleaned up when disposing server connections. So it is possible that the HubDispatcher is running when the server connection is disposed. Maybe v1.26 further exposed the issue.

@vicancy
Copy link
Member

vicancy commented Aug 15, 2024

It's interesting that v1.26 introduce in the error, the error should be always there. Hi @DevVanilli , is it possible for you to share with me a mini-project that could repro the issue that uses Autofac?

@dstj
Copy link

dstj commented Aug 27, 2024

@vicancy

Are you saying this should be fixed? Because after upgrading from Microsoft.Azure.SignalR" Version="1.26.0" to Microsoft.Azure.SignalR" Version="1.26.1", I see this error many, many times every time I deploy a new version of my app on Azure (Docker container):

HResult -2146232798
Message Cannot access a disposed object.Object name: 'IServiceProvider'.
ObjectName IServiceProvider
Source Microsoft.Extensions.DependencyInjection
StackTrace at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
  at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.OnDisconnectedAsync(HubConnectionContext connection, Exception exception)
  at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.HubOnDisconnectedAsync(HubConnectionContext connection, Exception exception)
TargetSite Void ThrowObjectDisposedException()
Type System.ObjectDisposedException

@creasoft-dag
Copy link

We encounter the same problem, is there any solution?
I updated to v1.27.0 and the error is still there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants