locked
How to send single messages being sent to a group? RRS feed

  • Question

  • User-467411554 posted

    I've setup groups in signalr using a unique id. Client side, I call JoinGroup method of signalr hub using a unique id and I have that unique id on my server as well to send message to that specific group from server to client.

    Now, I am executing some logic in functions app's function, on success of execution, I am sending message to that specific unique id group where the user had joint from client side and I see that message on client as well. The code to send message is setup in business logic project where I initialize connection to signalr with the hub url of my hosted hub in web application.

    Problem occurs, when the app service that contains web app scales out to more than 1 instance. Now, when the same function executes the logic, it sends multiple messages on client which is not expected. I tried handling this multiple message behavior on client but that breaks on a specific condition of the logic so can't do that.

    So, how do I troubleshoot this issue and fix it such that always a single message is sent from server/function to client.

    Friday, October 2, 2020 2:38 PM

All replies

  • User-474980206 posted

    if you are scaling out (more than 1 signal/r hub) be sure configured correctly.

      https://docs.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-3.1

    you have the same issue with recovery. you need a persistent store (database or redis)  to track sending of status messages.

    Friday, October 2, 2020 3:13 PM
  • User-467411554 posted

    I am using Azure SignalR.. But still facing this issue..

    Friday, October 2, 2020 3:47 PM
  • User-474980206 posted

    as I stated, you need a persistent store to track the sending of messages. this is also useful, if new clients need old messages.

    Friday, October 2, 2020 7:49 PM
  • User-467411554 posted

    Yes, but I can't use persistent storage as it would kill the purpose of sending the message in real time.. I tried Azure Signalr to eliminate this issue but still it is occuring.. I have turned off ARR in app service and turned on Web sockets for my web application app service.. Is there anything else that I can do ?

    Thursday, October 8, 2020 8:03 AM