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

Use sticky service connections for ackable messages #1779

Merged
merged 2 commits into from
Apr 24, 2023

Conversation

KKhurin
Copy link
Contributor

@KKhurin KKhurin commented Apr 14, 2023

This ensures correct order of ackable and non ackable messages.

For example, the following scenarios may occasionally fail (due to race condition) without this fix:

  • Removing after send should not prevent sending message to group:
{
 await Groups.AddToGroupAsync(connId, group);
 await Clients.Group(group).SendAsync(method, msg); // msg may never get delivered to connId
 await Groups.RemoveFromGroupAsync(connId, group);
}
  • Messages sent to a group should not get delivered to connections added to group afterwards:
{
 await Groups.RemoveFromGroupAsync(connId, group);
 await Clients.Group(group).SendAsync(method, msg); // msg may get sent to connId even though it is only added after SendAsync.
 await Groups.AddToGroupAsync(connId, group);
}

Note:

The race conditions affecting the scenarios above are rare and they should work most of the time. However, if your App logic depends on such scenarios, then please update to the future SDK version that will contain this fix.

@KKhurin KKhurin requested a review from vicancy April 14, 2023 08:21
@KKhurin KKhurin merged commit 7fc2ad8 into dev Apr 24, 2023
5 checks passed
@KKhurin KKhurin deleted the UseStickySrvForAckable branch April 24, 2023 22:56
terencefan pushed a commit to terencefan/azure-signalr that referenced this pull request May 5, 2023
* Use sticky service connections for ackable messages

* Update ServiceConnectionContainerBase.cs

adding more comments
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

Successfully merging this pull request may close these issues.

None yet

2 participants