Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR groups - filtering handled on client or server?

I've been reading a decent amount regarding SignalR hubs and groups. In particular, I've noticed that you cannot get a count of the connections in a particular group.

Is the filtering for groups handled on the client or server? If the server, why can't SignalR expose a count? If on the client, is there a way to send messages only to particular clients?

like image 300
David Pfeffer Avatar asked Jun 21 '12 17:06

David Pfeffer


People also ask

How many groups can SignalR handle?

Yes, it will work since the Microsoft documentation says that you can create 1 group per user/connection, so it depends by user limit and not group limit. So if your SignalR service can handle 40k+ users, it will handle 40k+ groups.

What are groups in SignalR?

Groups in SignalR provide a method for broadcasting messages to specified subsets of connected clients. A group can have any number of clients, and a client can be a member of any number of groups. You don't have to explicitly create groups.

How many clients can SignalR handle?

Since a browser is limited to six connections, we can try to manually monitor how many connections are supported by a given browser.

Is SignalR bidirectional?

ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available.


1 Answers

When you send a message to a particular group of specific connection, filtering happens on the server (there's no filtering, you're just addressing that one connection or group).

SignalR is based on pub sub so there's no list of connections per se. If you want to keep track of a list of connections then you have to handle the connection and disconnect events and persist them in memory or some persistent storage.

The reason we don't give you a list of connections is because any state we store hurts scaling out across nodes. If we gave you a list of connections, it's a pit of failure, because if you add another web node to your farm, you suddenly have to synchronize state across it. We let you address individual connections or groups via their identifier and that allows us to use the message bus to publish to all subscribers of that identifier.

like image 102
davidfowl Avatar answered Sep 28 '22 08:09

davidfowl