Reputation: 41
I am new to both SignalR and Redis. I have an ASP.NET Core SignalR app, and I am trying to do a proof of concept on using Redis as a backplane when it is scaled out, as described here: https://learn.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-2.2#redis-backplane
To test this on a small scale, I created two separate projects of the demo SignalR chat application described here: https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-2.2&tabs=visual-studio
I opened two instances (clients) of each demo app, and verified that each instance sends messages back and forth between its own clients.
pre-Redis screenshot, 2 working demo apps
Next, I installed a local Redis database, using version 3.0.504 of the Windows MSI file found here: https://github.com/microsoftarchive/redis/releases
Using redis-cli.exe, I see that I can connect to the local Redis instance:
127.0.0.1:6379> CLIENT SETNAME 'MyLocalConnection'
OK
127.0.0.1:6379> CLIENT LIST
id=22 addr=127.0.0.1:57283 fd=9 name=MyLocalConnection age=158 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
Next, I updated both of my demo apps, based on these instructions: https://learn.microsoft.com/en-us/aspnet/core/signalr/redis-backplane?view=aspnetcore-2.2
I installed NuGet Package Microsoft.AspNetCore.SignalR.StackExchangeRedis v1.1.5, and updated the startup.cs file:
//services.AddSignalR();
services.AddSignalR().AddStackExchangeRedis("localhost");
I started both apps, and using redis-cli.exe, I verified that both seem to be connecting properly:
127.0.0.1:6379> CLIENT LIST
id=29 addr=127.0.0.1:53692 fd=13 name=DESKTOP-ALLBLN9 age=11 idle=10 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=get
id=30 addr=127.0.0.1:53693 fd=11 name=DESKTOP-ALLBLN9 age=11 idle=9 flags=N db=0 sub=5 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=subscribe
id=31 addr=127.0.0.1:53695 fd=10 name= age=10 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
id=32 addr=127.0.0.1:53696 fd=9 name=DESKTOP-ALLBLN9 age=10 idle=9 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=get
id=33 addr=127.0.0.1:53697 fd=12 name=DESKTOP-ALLBLN9 age=10 idle=8 flags=N db=0 sub=5 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=subscribe
127.0.0.1:6379>
At this point, I open two clients for each app again, expecting that a message sent by any one will reach all four clients. But, it still only reaches the two clients for that specific app.
After Redis added, clients still only talk to their own app
Can someone help me understand what my mistake is here? Is there more I need to add to get both applications to "see" each other? Or am I misunderstanding how the Redis backplane is supposed to work?
Upvotes: 3
Views: 3381
Reputation: 82
The name of the projects should be the same. redis adds the project name to the name of the channels. because different project names are on different channels, they cannot message.
Upvotes: 1