websocketsignalrload-balancingsignalr-backplanesignalr-2

SignalR combined with load balancer missing messages


I have 2 web servers (IIS 8.5) behind a hardware firewall and our application uses SignalR for some real-time updates. We are using SQL Server as the backplane to help us work in this load balanced environment. Additionally we are using sticky sessions on the load balancer to help us keep the users on the same web server during their session. When we are running in this hardware configuration we lose at least 1/3 of our messages. Sometimes we get all the expected messages but more often than not we are missing plenty.

When we are running on a single web server all messages are received. Does anyone have any suggestions for troubleshooting this problem? We've turned on logs (both client & server) and nothing looks like it's missing or broken. We're really stumped.

EDIT---

Some additional details that I hope will shed light on the situation.


Solution

  • Finally resolved this. There were 2 issues really. The first is that we were using an in memory list of users as mentioned in the edit above. Once we realized that wasn't going to work across machines we removed it. It also led us to the second issue which was how SignalR 2 uses the IUserIdProvider and our call should have been

    Clients.User(userId).send(message)
    

    instead of

    context.Clients.Client(connection)
    

    This code had existed since we first started using SignalR many years ago and never got properly updated as we upgraded SignalR versions