Cannot Connect to a Redis Server Using ASP.NET Session State Provider

I am trying to replace an ASP.NET session with Redis for a while. The few hours with the Microsoft ASP.NET Session State Provider for Redis were fruitless.

We have a local Sentinel configuration for Redis. Initially, I thought this did not work due to the fact that the Provider does not support Sentinels. I switched my connection string to using the wizard, hoping that at least I could establish a connection. Nothing yet.

I tried several configurations for this provider and constantly got either "There is no connection available for request" or "Additional information: it was impossible to connect to redis servers, create a disconnected multiplexer, disable AbortOnConnectFail UnableToResolvePhysicalConnection on PING."

Here are some of my configurations:

Attempt # 1:

<connectionStrings> <add name="RedisConnection" connectionString="1.2.3.4:5,abortConnect=false,ssl=true,password=XXXXXX,ConnectTimeout=10000"/> </connectionStrings> <sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="RedisConnection" /> </providers> </sessionState> 

Attempt number 2:

 <sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="1.2.3.4" port="5" accessKey="XXXXXXX" /> </providers> </sessionState> 

Attempt No. 3:

 <sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="1.2.3.4:5" accessKey="XXXXXXX" /> </providers> </sessionState> 

I found very little documentation for this provider, and troubleshooting was a problem. I came across a third-party vendor and decided to try it, compared to the Microsoft vendor.

I was able to successfully connect to Harbor.RedisSessionStateStore using the following configuration:

 <sessionState mode="Custom" customProvider="RedisSessionStateProvider"> <providers> <clear /> <add name="RedisSessionStateProvider" type="Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider" host=" PASSWORD@1.2.3.4 :5" clientType="pooled" /> </providers> </sessionState> 

With this in mind, what is the correct format for the connection string for the Microsoft provider? It will be easier for me to get internal support from the first party library, and at that moment it would be a moral victory for this work to work.

Also, if anyone knows how I can configure this to get into Sentinel and determine the master instance to connect to, I would welcome a blog post or some share of knowledge on this topic.

Thanks!

+3
source share
1 answer

I can give an example of the working configuration that we have in our production, without a sentinel, but directly to the master:

 <system.web> <sessionState mode="Custom" customProvider="Custom_RedisSessionStateStore"> <providers> <add name="Custom_RedisSessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="your_host_name_goes_here" accessKey="" port="6379" ssl="false" operationTimeoutInMilliseconds="5000" /> </providers> </sessionState> </system.web> 
+2
source

All Articles