Signalr with redis backplane, sending message to user

Viewed 471

I am researching to use signalr to send messages from an api to a specific user (keyword). Locally, I have everything working as designed (even using redis backplane).

When I move up to an actual environment with multiple servers (azure app service), it seems like messages to specific users don't flow through the backplane. If I send a message to Clients.All it works. But, if I send a message to Clients.User(username), the message is never received. This works locally because it's a single server, but doesn't seem to work in multiple servers.

await this.impersonationContext.Clients.User(mainUserName).SendAsync("msguser", new object[] { mainUserName });
await this.impersonationContext.Clients.All.SendAsync("msg", new object[] { "wtf" });

If I call the above code, only the msg event is fired, but the msguser is never recieved.

Could I be missing something on the setup? That's my assumption, I cannot be the only one doing this.

Below is my setup in the startup.cs. This is using .net core 5 with the latest nugets, etc

services.AddSignalR(options =>
        {
            options.EnableDetailedErrors = true;
        })
        .AddStackExchangeRedis(this.Configuration["Redis:Cache"], options => {
            options.Configuration.ChannelPrefix = "ImpersonationService";
        });
services.AddSingleton<IUserIdProvider, NameUserIdProvider>();

Any help would be appreciated.

Update #1 Looks like the user info is being pushed through the backplane (username hidden). So maybe its the connection from javascript client? enter image description here

Update #2 Getting closer...looks like the subscription isn't setup for the specific user like I see locally. Could this be websockets? enter image description here

Update #3 Found it....sorta. I was missing the authorize attribute on the hub, which was allowing the websocket to connect, even though websockets isn't authenticating for some reason (different issue). Once I added the authorize, it will drop down to long polling with the user info and works as designed

0 Answers
Related