Search code examples
c#.netredissignalrredis-cli

SignalR Redis backplane implementation


Set up redis backplane per article: https://learn.microsoft.com/en-us/aspnet/core/signalr/redis-backplane?view=aspnetcore-3.1, how would one view published messages in redis?. I want to make sure redis pub/sub is actually being used without deploying it to 2 different nodes.

Configuration:

public void ConfigureServices(IServiceCollection services)
{
    services.AddSignalR().AddStackExchangeRedis("localhost:6379", options => {
        options.Configuration.ChannelPrefix = "MyApp";
    });

I would be able to see in redis-cli when a message is sent via (Hub => chat hub):

await Clients.All.SendAsync("broadcastMessage", name, message);

It doesn't show anything when subscribed: enter image description here


Solution

  • SUBSCRIBE will subscribe to the exact key that you give it, in this case "MyApp". That is the wrong name though as SignalR will use multiple channels to send messages and will just use "MyApp" as the prefix to the channel names.

    If you want to listen to all channels with "MyApp" at the beginning then you need to use PSUBSCRIBE and give it a pattern for the channel names (like "MyApp*").

    Or you can use the MONITOR command to view all the traffic over Redis.