Configure ASP.NET Redis Session State Provider to configure Sentinel

I have been trying to get the ASP.NET Redis Session State provider configured in my application for some time. Finally, I was able to successfully connect directly to the wizard and set / get the keys thanks to this message: Unable to connect to the Redis server using ASP.NET Session State Provider

Now, my next question is ... get this to work with the Sentinel configuration.

I am familiar with the SENTINEL get-master-addr-by-name master-dev-sessionstate command to define a master. Does this provider have this built-in? Based on the comments on the blog post linked above (this is also ONLY the documentation I can find on this), it looks like I should use the connectionString attribute to transfer multiple hosts. I'm not sure if these few hosts are for Sentinels or not.

 <connectionStrings> <add name="RedisConnection" connectionString="1.2.3.4:5,6.7.8.9:10,abortConnect=false,ssl=false,password=XXXXXX,operationTimeoutInMilliseconds=5000"/> </connectionStrings> <sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <clear/> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="RedisConnection"/> </providers> </sessionState> 

When setting up my connection like this, I get this error:

Additional Information: Failed to connect to redis Server (s); To create a disabled multiplexer, disable AbortOnConnectFail.

I get this error even if I only have the primary IP address in my connection string. As you can see above, I have abortConnect = "false" in my connection string, which teaches me how to do it. The same error occurs with or without this in the connection string.

With that in mind, here are my questions ...

  • Does this provider support Sentinel configuration?
  • If so, what is the correct format for the connection string?
  • Does anyone have any other good documentation resources? I couldn’t even find anything on the Microsoft site beyond this blog post.

EDIT: I should point out that this is a typical local Redis installation. We do not go through Azure.

EDIT: Recently, I tried to point my working configuration to Sentinel, and I get "No connection to service this operation: EVAL." This makes me think that this provider does not have Sentinel support. Can anyone confirm this?

+5
source share
2 answers

I use this provider to privately install redis. As far as I understood the documentation, this provider uses the package StackExchange.Redis.Strongname and ConnectionMultiplexer for configuration. You can use the configuration options described in this library. In addition, this documentation states that support for the gatekeeper (serviceName) is currently not implemented.

However, I wonder why you need to communicate with sentries, ConnectionMultiplexer can enable the configuration of the master slave in the "Documentation" section. Moreover, I tested this behavior by disabling redis instances and looking at network traffic. Please see the ConnectionMultiplexer documentation:

A more complex scenario may include installing a master / slave; for this use, simply specify all the necessary nodes that make up this logical retry level (it automatically identifies the wizard): ConnectionMultiplexer redis = ConnectionMultiplexer.Connect ("server1: 6379, server2: 6379");

In addition, my configuration setup is as follows:

  <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="XXXXXX:6379,XXXXXX:6379,XXXXXX:6379" applicationName="myFancyApp"ssl="false"/> 

As for the MS.RedisSessionState provider, I used the following tutorial next to the site .

+2
source

This is what is usually added to web.config when installing the nuget package;

 sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <!-- <add name="MySessionStateStore" host = "127.0.0.1" [String] port = "" [number] accessKey = "" [String] ssl = "false" [true|false] throwOnError = "true" [true|false] retryTimeoutInMilliseconds = "0" [number] databaseId = "0" [number] applicationName = "" [String] connectionTimeoutInMilliseconds = "5000" [number] operationTimeoutInMilliseconds = "5000" [number] /> --> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="127.0.0.1" accessKey="" ssl="false" /> </providers> </sessionState> 

Here we use the Azure cache server.

 <sessionState mode="Custom" customProvider="DefaultSessionProvider"> <providers> <add name="DefaultSessionProvider" type="Microsoft.Web.Redis.RedisSessionStateProvider" port="6380" host="xxxxxxxx.redis.cache.windows.net" accessKey="vCG........We0n=" ssl="true" connectionTimeoutInMilliseconds = "5000" operationTimeoutInMilliseconds = "1000" retryTimeoutInMilliseconds="3000" /> </providers> </sessionState> 

We set the reuse time to 3 seconds with a response time of up to 1 second, which allows 3 (1000/3000 = 3) attempts to fail.

0
source

All Articles