Replies: 2 comments 1 reply
-
https://learn.microsoft.com/aspnet/core/signalr/hubs?view=aspnetcore-9.0#create-and-use-hubs
|
Beta Was this translation helpful? Give feedback.
-
It is not about a user log in or not. If there is a connected connection, a SigalR hub get created from Then a new connection is started. A new SignalR hub get created from |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone.
During debugging my project I found something interesting for a project that uses SignalR.
If a user does not log in to a website, a custom SignalR Hub is created two times after starting a SignalR connection.
If a custom Hub has an overridden OnConnectedAsync method, it is called on second instance.
On the other hand, if a user has logged in to a website, a custom hub is created only one instance and OnConnectedAsync is called immediately.
Here is the simple project to reproduce this behavior.
https://github.com/aaronamm/aspnetcore-signalr-sample/blob/develop/PingHub.cs#L7
I tried to figure it out and reason why a custom hub get created two times when a user does not log in.
https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs#L104
However, I still can't reason about it. There must be some logic to check if a user has logged in or other checking logic but I couldn't find it.
If someone is familiar with this area, please let me know why a custom hub get created two times when a user does not log in.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions