We are currently looking to switch from redis hosted in-house to Azure Redis Cache.
On modifying the connection string with the azure redis host name and password, I started getting “invalid password” exceptions.
Digging in, via the debugger I noticed that
(RedisResolver)this._pooledClientManager.RedisResolver).Masters[0].Password
is missing the trailing “=” sign.
The code that hydrates this looks correct to me:
_pooledClientManager =
new PooledRedisClientManager(
writeHostEndpoints.Select(endpoint => endpoint.ToString()),
readHostEndpoints.Select(endpoint => endpoint.ToString()),
XEnvironment.ConnectionPoolSize.HasValue
? new RedisClientManagerConfig
{
MaxWritePoolSize = XEnvironment.WriteHosts.Length*XEnvironment.ConnectionPoolSize.Value,
MaxReadPoolSize = XEnvironment.ReadHosts.Length*XEnvironment.ConnectionPoolSize.Value
}
: null) {PoolTimeout = XEnvironment.ConnectionPoolTimeout, ConnectTimeout = XEnvironment.SocketConnectionTimeout};
Note that
writeHostEndpoints.Select(endpoint => endpoint.ToString()
and
readHostEndpoints.Select(endpoint => endpoint.ToString())
both yield endpoints that still contain the trailing “=” , so it seems like the issue is somewhere in PooledRedisClientManager.
I did the following workaround hack so that I could continue my Azure Redis evaluation, though I would strongly prefer a fix or some guidance on what I did wrong.
var redisResolver = ((RedisResolver)this._pooledClientManager.RedisResolver);
for (int i = 0; i < redisResolver.Masters.Count(); i++)
{
var ep = redisResolver.Masters[i];
if (ep.Password != XEnvironment.ConnectionPassword)
{
ep.Password = XEnvironment.ConnectionPassword;
}
}
for (int i = 0; i < redisResolver.Slaves.Count(); i++)
{
var ep = redisResolver.Slaves[i];
if (ep.Password != XEnvironment.ConnectionPassword)
{
ep.Password = XEnvironment.ConnectionPassword;
}
}
Thank you!