A set of technologies in the .NET Framework for building web applications and XML web services.
AddStackExchangeRedis expects either a full Redis connection string or a ConfigurationOptions object, not just the logical name of the connection string.
In the code, this line:
builder.Services.AddSignalR().AddStackExchangeRedis("cache");
passes the literal string "cache" to StackExchange.Redis, so it tries to connect to a server named cache on the default port, which fails.
Use the actual connection string instead, for example by reading it from configuration:
var redisConnectionString = builder.Configuration.GetConnectionString("cache");
builder.Services
.AddSignalR()
.AddStackExchangeRedis(redisConnectionString);
With the appsettings.json entry:
"ConnectionStrings": {
"cache": "localhost:6379,password=FxxawDPpD1Tscj9pt2upxH,abortConnect=false"
}
Also ensure that the Redis server is actually running and reachable at localhost:6379 from the Chat_Presense project container/process. In containerized Aspire setups, localhost usually refers to the container itself, not the AppHost; use the service host name and port that Aspire assigns (for example, the resource name) in the connection string if needed.
References:
- Set up a Redis backplane for ASP.NET Core SignalR scale-out
- StackExchangeRedisDependencyInjectionExtensions.AddStackExchangeRedis Method
- Azure Cache for Redis development FAQs
- Connection resilience
- Connection resilience with Azure Managed Redis
- AspireMicrosoftAzureStackExchangeRedisExtensions Class
- SignalR Scaleout with Redis