0

When you configure SignalR to use a SQL Backplane and you send to a group, does SignalR create in the backplane one message for the group or one message for each client ID in the group.

I need two instances of my SignalR, but because clients have different connectionIds between instances, I need to send message to a unique identifier which could be the group.

Can anyone please answer this ? Thanks

J41r0k
  • 3
  • 2

1 Answers1

1

Each server instance connects to the backplane through the bus. When a message is sent, it goes to the backplane, and the backplane sends it to every server. When a server gets a message from the backplane, it puts the message in its local cache. The server then delivers messages to clients from its local cache.

As per: http://www.asp.net/signalr/overview/performance/scaleout-in-signalr

This means that the server (hub) would decide how to handle the message so you can do either.

This might help. http://www.asp.net/signalr/overview/performance/scaleout-with-sql-server

Kelso Sharp
  • 972
  • 8
  • 12
  • Thank you for the answer, but can you please explain how I can handle the message in the Hub. As far as I know, the hub allows me to manage connection/disconnection of clients, nothing more.... – J41r0k Jul 26 '16 at 19:55
  • Using a custom pipeline ? – J41r0k Jul 26 '16 at 20:03
  • I don't think that you understand the purpose of the backplane, there is nothing that you need to do for the backplane to work once you have it set up. All of your messaging and handling of messages is done in the Hub, meaning you would use the signlar application exactly the same way you would without the backplane. So if you want to broadcast to a specific client, you would set that all up yourself, either with a group, or with a connectionid in the onConnected event. – Kelso Sharp Jul 26 '16 at 20:03
  • "When a server gets a message from the backplane, it puts the message in its local cache. The server then delivers messages to clients from its local cache." If i have a message sitting up on backplane's RabbitMq queue, how does it get delivered to a particular listening group in the hub? – Sergey Akopov Apr 12 '17 at 21:03
  • @SergeyAkopov through the hub and group names and the IMessageBus its in the link in my original answer. For each client connection, the client's progress in reading the message stream is tracked using a cursor. (A cursor represents a position in the message stream.) If a client disconnects and then reconnects, it asks the bus for any messages that arrived after the client's cursor value. The same thing happens when a connection uses long polling. After a long poll request completes, the client opens a new connection and asks for messages that arrived after the cursor. – Kelso Sharp Apr 13 '17 at 18:28
  • I get how the entire thing works in case of a user-generated action (ie chat). How does this work when it's a server-generated action that needs to distribute a message to a very particular group of connected clients. My backplane gets the message that's on the exchange. But the clients don't get anything. And AFAIK the backplane isn't suppossed to do that. Somehow, somewhere I need to get the HubContext, get a group of clients on it and call a dynamic function on that group. But I have no clue where and outside of silly chat examples there isn't much explaining that. – Sergey Akopov Apr 13 '17 at 19:27
  • 1
    Oh!! ok now I understand, this is not a backplane issue.. try this IHubContext context = GlobalHost.ConnectionManager.GetHubContext(); – Kelso Sharp Apr 13 '17 at 19:36
  • Yep. And I currently have that sitting in an API controller action that runs alongside SignalR. And have a process that hits it to notify connected clients. I was hoping that a backplane would allow me to simply drop messages on an exchange and have SignalR backplane pick them up and distribute them out instead of going thru this endpoint. But this doesn't appear to be the usecase at all. Thanks for clarifying! – Sergey Akopov Apr 13 '17 at 20:06