admin管理员组

文章数量:1402829

I have an asp core signlar application which essentially consumes messagages from a rabbitmq server and "broadcasts" them to all "connected" clients using signalr, i.e.:

var start = Stopwatch.GetTimestamp();
await hubContext.Clients.All.SendCoreAsync("NewMessage", [message]);
Console.WriteLine(Stopwatch.GetElapsedTime(start));

What I notice is that this can take anywhere from less than 1 second...to upwards of 10 minutes.

Our application does push quite a lot of messagse to clients...so I assume what's happening is that some clients are unable to keep up (perhaps due to insufficent network bandwidth) or even that they've been disconnected...but signarlr still thinks they are connected.

However, the docs for this method say that this method:

Does not wait for a response from the receiver.

However, this comment on a related dotnet github issue is a bit ambiguous

In general, a slow client should not affect when the SendAsync completes. However, if there's a long backlog of messages waiting for a single client and the client has disconnected (and is thus not recieving them), then you can end up blocked.

Is there someway I can see if there are a 'backlog of messages waiting for a single client'?

How can I prevent a 'dodgy' client from negatively impacting the performance for all users? Should i simply not await this method?

本文标签: performanceHow does IHubClientsSendCoreAsync behave when a client is slowdiscconnectedStack Overflow