Skip to content

Commit

Permalink
Fix the ack message issue when MapHub for the same hub is called mult…
Browse files Browse the repository at this point in the history
…iple times (#2021)

* Fix the ack message issue when MapHub for the same hub is called multiple times

* Update ServiceConnectionContainerBase.cs
  • Loading branch information
vicancy authored Aug 15, 2024
1 parent 4b1e0f5 commit 08d0ffa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ protected ServiceConnectionContainerBase(IServiceConnectionFactory serviceConnec
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
ServiceConnectionFactory = serviceConnectionFactory;
Endpoint = endpoint;
_ackHandler = ackHandler ?? new AckHandler();
// use globally unique AckHanlder if not specified
// It is possible that the multiple MapHub calls the same hub, so that ack messages could be received by another instance of ServiceConnectionContainer
// Use the ack handler singleton to allow ack message to be acked by another container instance
_ackHandler = ackHandler ?? AckHandler.Singleton;

// make sure it is after _endpoint is set
// init initial connections
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.Azure.SignalR.Common/Utilities/AckHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Azure.SignalR
{
internal sealed class AckHandler : IDisposable
{
public static readonly AckHandler Singleton = new();
private readonly ConcurrentDictionary<int, IAckInfo> _acks = new();
private readonly Timer _timer;
private readonly TimeSpan _defaultAckTimeout;
Expand Down

0 comments on commit 08d0ffa

Please sign in to comment.