ConnectionSelectionStrategy not working as expected
Describe the bug I have decided to use StackExchange.Redis.Extension due to its connection pooling feature. Currently i am testing it in one of my project but not getting expected results. I have 2 redis servers (no master slave, no cluster ,no sentinel) and want to use both as active active with round robin Strategy. But despite of adding both IPs in configuration and even adding both configuration all keys are written into 1st instance of redis and there are no keys on 2nd instance.
To Reproduce 2 standalone redis servers connected to asp.net core application.
Expected behavior While using round robin Strategy, 1 request should go to the Redis1 and other to Redis2 instance. Similarly when 1st instance of redis is shutdown then it also throws exception, while if 1st instance of redis is down then request should be entertained by 2nd instance.
Screenshots / StackTrace
Here is implementation 1. Round robin not working but switching to 2nd instance if 1st instance goes down.
` var configurations = new[]
{
new RedisConfiguration
{
AbortOnConnectFail = true,
Hosts = new[] {
new RedisHost { Host = "172.21.21.105", Port = 6379 },
new RedisHost { Host = "172.21.21.106", Port = 6379 },
},
AllowAdmin = true,
ConnectTimeout = 5000,
Database = 0,
PoolSize = 100,
IsDefault = true,
Name = "Instance1",
ConnectionSelectionStrategy=ConnectionSelectionStrategy.RoundRobin,
ServerEnumerationStrategy =serverEnumartions
},'
Implementation2 Round Robin not working also not switching to 2nd instance when 1st instance goes down.
` var configurations = new[]
{
new RedisConfiguration
{
AbortOnConnectFail = true,
Hosts = new[] {
new RedisHost { Host = "172.21.21.106", Port = 6379 },
},
AllowAdmin = true,
ConnectTimeout = 5000,
Database = 0,
PoolSize = 100,
IsDefault = true,
Name = "Instance1",
ConnectionSelectionStrategy=ConnectionSelectionStrategy.RoundRobin,
ServerEnumerationStrategy =serverEnumartions
},
new RedisConfiguration
{
AbortOnConnectFail = true,
Hosts = new[] { new RedisHost { Host = "172.21.21.107", Port = 6379 } },
AllowAdmin = true,
ConnectTimeout = 5000,
Database = 0,
PoolSize = 100,
Name = "Instance2",
ConnectionSelectionStrategy=ConnectionSelectionStrategy.RoundRobin,
ServerEnumerationStrategy =serverEnumartions
}'
Environment:
- OS: Redis instance on RHEL-7
- Runtime version [.NET Core 6.0 ....] -Application running from windows 10 machine.
Hi @khushwaqt
we release the 10.0.2 that should contains a fix for the issue you got.
Here https://github.com/imperugo/StackExchange.Redis.Extensions/pull/579 the explaination and the fix.
Could you try it and let us know? Thanks