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

AddToGroupAsync throws a TimeoutException exception when MapHub is called twice for the same hub #2003

Closed
sasha-khadasevich opened this issue Jul 25, 2024 · 4 comments · Fixed by #2021
Assignees

Comments

@sasha-khadasevich
Copy link

sasha-khadasevich commented Jul 25, 2024

Describe the bug

Groups.AddToGroupAsync() throws a TimeoutException approximately half the time when MapHub is called twice for the same hub. This issue is caused by changes introduced in #1779. It can be reproduced with Microsoft.Azure.SignalR version 1.21.3 or later works fine with version 1.21.2.

I'm unsure if calling MapHub twice for the same hub is allowed. If it isn't, this behavior should be documented.

To Reproduce

Update the ChatRoom sample project as follows:

Program.cs

app.MapHub<ChatSampleHub>("chat"); 
app.MapHub<ChatSampleHub>("chat/v2");

ChatSampleHub.OnConnectedAsync
await Groups.AddToGroupAsync(Context.ConnectionId, $"{Guid.NewGuid()}");

Exceptions (if any)

fail: Microsoft.AspNetCore.SignalR.HubConnectionHandler[1]
Error when dispatching 'OnConnectedAsync' on hub.
System.TimeoutException: Ack-able message Microsoft.Azure.SignalR.Protocol.JoinGroupWithAckMessage(ackId: 1) timed out.
at Microsoft.Azure.SignalR.AckHandler.HandleAckStatus(IAckableMessage message, AckStatus status)
at Microsoft.Azure.SignalR.ServiceConnectionContainerBase.WriteAckableMessageAsync(ServiceMessage serviceMessage, CancellationToken cancellationToken)
at Microsoft.Azure.SignalR.MultiEndpointMessageWriter.<>c__DisplayClass10_0.<b__0>d.MoveNext()

Further technical details

  • Your Azure SignalR SDK version - 1.21.3
  • .NET Version: 8

Tasks

Preview Give feedback
No tasks being tracked yet.
@sasha-khadasevich sasha-khadasevich changed the title AddToGroupAsync throws TimeoutException exception when MapHub for Hub called twice AddToGroupAsync throws a TimeoutException exception when MapHub is called twice for the same hub Jul 25, 2024
@vicancy vicancy self-assigned this Aug 13, 2024
@vicancy
Copy link
Member

vicancy commented Aug 13, 2024

Thanks for reporting the issue, yes I can consistently repro the issue, please allow me to take a further look.

@vicancy
Copy link
Member

vicancy commented Aug 14, 2024

To double confirm, the behavior, as the same as self-host SignalR, is that although they map to different endpoints chat and chat/v2, these clients are actually sharing the same Hub, a sendToAll message send to all these clients despite they connect to different endpoint.

Curious about the usage, is it for rolling update the client logic?

@sasha-khadasevich
Copy link
Author

sasha-khadasevich commented Aug 14, 2024

In our project, we used something like chat/v1 and chat/v1.0 to follow different conventions for clients. We faced issues after updating from version 1.21.2 to the latest one and spent a lot of time figuring out what was wrong (cause error message and stack trace are not precise). Right now, we definitely don't need to register the hub for two URLs. We removed it and are happy with the update, but I believe it would be nice to fix or document this limitation, as someone else might face the same issue in the future.

@vicancy
Copy link
Member

vicancy commented Aug 15, 2024

Thanks for sharing Sasha, the next release will fix the issue.

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