I have an on-premises Redis environment set up with Sentinels for failover. I am attempting to use Redis as my SessionStateProvider within my MVC application. I have installed the Microsoft.Web.RedisSessionStateProvider NuGet package, and I have the web.config entry for my provider. Reading through Microsoft's announcement blog post for this provider, it seems that support for multiple hosts was just added via the connectionString property.
Question asked via comments on the announcement blog post:
@Siddarth
The StackExchange.Redis Redis client allows for multiple hosts to be listed using the ConnectionMultiplexer, as seen github.com/.../Basics.md. How could I go about setting multiple hosts to pass through to the Redis client? In a previous comment you mentioned opening up the optionsString that can be set, in which case we would be able to pass through multiple hosts.
The response:
@Dvorac
ConnectionMultiplexer redis = >ConnectionMultiplexer.Connect("server1:6379,server2:6379");
you can pass this "server1:6379,server2:6379" using "connectionString" settings in session state provider.
I have attempted to find further documentation than this blog post and comments, but I have been unable to find anything substantial. On my journey to find more information, I believe I read that the provider should get able to determine which is the master by iterating through all of the provided hosts.
As of now, I am 99% certain I need to use the connectionString to allow for multiple hosts, though I am barely 1% sure that this RedisSessionStateProvider has Sentinel support. I have been struggling to craft a proper connectionString, and am currently faced with the following exception:
An exception of type 'StackExchange.Redis.RedisConnectionException' occurred in Microsoft.Web.RedisSessionStateProvider.dll but was not handled in user code
Additional information: No connection is available to service this operation: EVAL
My connectionString as it stands follow this format:
connectionString="1.2.3.4:5,1.2.3.4:5,1.2.3.4:5,1.2.3.4:5,1.2.3.4:5,1.2.3.4:5,ssl=true,password=XXXXXX,abortConnect=false"
If anyone has any information that could lead me in the proper direction, I would greatly appreciate it.
I have set up a telnet and I've sent messages to the Redis server, so I know I have access and can establish a connection from my machine. I can't help but feel that I either have not written my connectionString properly of that the ASP.NET Session State Provider cannot handle this configuration and I should look to build something custom.