Receiving the following error when attempting to access a serverless Redis cache:
StackExchange.Redis.RedisConnectionException: The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: UnableToConnect
My high-level setup is:
I am attempting to access it from an ASP.NET Core application using the AddStackExchangeRedisCache
extension from the Microsoft.Extensions.Caching.StackExchangeRedis package.
Not sure what else is missing for the task to be able to reach the cache.
After a lot of tweaking and looking around I finally noticed that the serverless caches have Encryption in Transit
enabled by default.
At the same time, I was not explicitly setting Ssl
to true in my ConfigurationOptions
when adding the Redis service in my application startup. By default this is false, and so there was a mismatch between the cache and my server in regards to encryption.
The final solution for adding the service resembles:
services.AddStackExchangeRedisCache(delegate (RedisCacheOptions options)
{
options.ConfigurationOptions = new ConfigurationOptions()
{
EndPoints = new EndPointCollection { "your-cache.serverless.use1.cache.amazonaws.com:6379" },
Ssl = true,
ConnectRetry = 3,
ReconnectRetryPolicy = new LinearRetry(250),
AbortOnConnectFail = false,
ConnectTimeout = 500,
SyncTimeout = 500
};
});