Code is as below -
services.AddSignalR()
.AddStackExchangeRedis("*****.*****.com:6379", opts =>
{
opts.Configuration.ChannelPrefix = "SomeMessage";
opts.Configuration.Ssl = true;
opts.Configuration.AbortOnConnectFail = true;
opts.Configuration.ConnectRetry = 3;
opts.Configuration.ConnectTimeout = 30;
})
;
subscribe looks as below
public Task Subscribe(string subscriptionKey)
{
return Groups.AddToGroupAsync(Context.ConnectionId, subscriptionKey);
}
broadcast method look as below
public Task SendMessage(SendMessageModel sendMessageModel)
{
return Clients.Group(sendMessageModel.subscriptionKey).SendAsync(sendMessageModel.eventType, sendMessageModel.payload);
}
I am getting the broadcasted messages in client application and seems to be working fine, however I do not have direct access to redis database. How to verify with C# code that key value pairs are stored in redis elasticache?
I have tried a testMethod to connect to same redi elasticache and saved foo <> bar keyvalue pair in it, and could retrieve the value with key. shown in below code.
ConnectionMultiplexer cluster = ConnectionMultiplexer.Connect("******.****.com:6379,connectTimeout=30000,responseTimeout=30000,ssl=true,abortConnect=true,syncTimeout=30000");
IDatabase db = cluster.GetDatabase();
db.StringSet("foo", "bar");
var getResult = db.StringGet("foo");
_loggerUtility.LogGenericMessage(LogType.DEBUG, "After getdb of calling Controller TestAsync() cluster value : " + getResult);
I want to do something similar to check key value pair for signal R messages but not sure what key is stored in redis cache. can you please let me know how to approach ?