Creating 2nd connection to to Redis sentinel deployment using the same ConfigurationOptions instance fails with exception.
What is expectedCreating multiple connections with the same configuration instance should succeed.
What is observedFailure with exception.
It looks like ConfigurationOptions
instance passed to ConnectionMultiplexer.Connect
is getting modified.
SetupNOTE: Cloning
ConfigurationOptions
before connect also does not work.
Redis sentinel deployment with 2 slaves : Docker compose is attached.
OS : Ubuntu 20.04 LTS
.NET Core Version : 3.1.25
Redis NuGet Package Version: StackExchange.Redis 2.5.61
Start the sentinel cluster with default sentinel port
docker-compose up --scale redis-sentinel=3 -d
Run the below sample application.
Demo sample program
using System; using System.IO; using System.Net; using System.Net.NetworkInformation; using System.Runtime.InteropServices; using StackExchange.Redis; namespace netcore31 { class Program { static void Main(string[] args) { ConfigurationOptions configurationOptions = ConfigurationOptions.Parse("localhost"); configurationOptions.ServiceName = "mymaster"; configurationOptions.Password = "str0ng_passw0rd"; // 1st Connection using var firstConnection = ConnectionMultiplexer.Connect(configurationOptions); System.Console.WriteLine(firstConnection.GetStatus()); IDatabase database = firstConnection.GetDatabase(); database.StringSet("SomeKey","SomeValue"); System.Console.WriteLine(database.StringGet("SomeKey")); // Eastblishing second connection 2nd throws exception using var secondConnection = ConnectionMultiplexer.Connect(configurationOptions); System.Console.WriteLine(secondConnection.GetStatus()); } } }
ConfigurationOptions object passed to ConnectionMultiplexer.Connect is getting changed hence
https://hub.docker.com/r/bitnami/redis-sentinel/
version: '2' networks: app-tier: driver: bridge services: redis: image: 'bitnami/redis:latest' environment: - REDIS_REPLICATION_MODE=master - REDIS_PASSWORD=str0ng_passw0rd networks: - app-tier ports: - '6379' redis-slave: image: 'bitnami/redis:latest' environment: - REDIS_REPLICATION_MODE=slave - REDIS_MASTER_HOST=redis - REDIS_MASTER_PASSWORD=str0ng_passw0rd - REDIS_PASSWORD=str0ng_passw0rd ports: - '6379' depends_on: - redis networks: - app-tier redis-sentinel: image: 'bitnami/redis-sentinel:latest' environment: - REDIS_MASTER_PASSWORD=str0ng_passw0rd depends_on: - redis - redis-slave ports: - '26379-26381:26379' networks: - app-tier
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4