2

Related question is here: Get number of listeners, clients connected to SignalR hub

2 years have passed, vNext was introduced with SignalR 3 and I'd like to know if there's any default way of getting count of connected clients to a particular connection OR is it planned to introduce this functionality to SignalR 3 later on?

Dovydas Navickas
  • 3,533
  • 1
  • 32
  • 48

1 Answers1

6

Nope, because it will never work when you're scaled out across multiple servers. Making something like that reliable (for all application types) is hard and will be a bug farm when people start depending on it to be completely accurate. So your best bet is to keep track of the connections and presence on your own.

davidfowl
  • 37,120
  • 7
  • 93
  • 103
  • 1
    Thought so :) Just wanted to it from you. – Dovydas Navickas Jul 07 '15 at 17:15
  • 1
    Hi, David. I have an edge case for that maybe you have a solution for. If you use the recommended pattern of connect/disconnect override for tracking users and connections. And if your business rules need you to detect when the client has closed their last remaining connection. If the server goes down, the connection is obviously closed, but the cache of the user/connection mapping would remain. So on restart, logic checking the count of remaining connections for that user will be off by 1 and never reach zero until expiration of that item in the cache. Do you recommend a way to prevent this? – Bon Jul 22 '15 at 15:05