最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

performance - How does IHubClients.SendCoreAsync behave when a client is slowdiscconnected? - Stack Overflow

programmeradmin4浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论