4

I have been attempting to replace ASP.NET Session with Redis for some time now. Multiple hours with the Microsoft ASP.NET Session State Provider for Redis have been fruitless.

We have an on-premises Sentinel configuration for Redis. Originally I thought this was not working due to the Provider not supporting Sentinels. I switched my connection string to use the master, in hopes that I would at least be able to establish a connection. Still nothing.

I have tried multiple configurations for this provider and continually receive either "No connection available for the request" or "Additional information: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on PING."

Here are some of the configurations I've attempted:

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 #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 #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 have found very little documentation on this provider, and troubleshooting has been a challenge. I came across a third-party provider and decided to try it, compared to the Microsoft provider.

I was able to successfully connect with Harbour.RedisSessionStateStore, using the following configuration:

<sessionState mode="Custom" customProvider="RedisSessionStateProvider">
  <providers>
    <clear />
    <add name="RedisSessionStateProvider" type="Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider" host="[email protected]:5" clientType="pooled" />
  </providers>
</sessionState>

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

Also, if anyone knows how I could configure this to hit the Sentinel and determine the master instance to connect to, I would welcome a blog post or any sort of knowledge share on the topic.

Thank you!

4
  • Are you using Azure Redis Cache? or a local/cloud custom server? Commented Aug 27, 2015 at 2:09
  • Local, custom server. Commented Aug 27, 2015 at 12:44
  • I'd try to replicate your scenario. Is your redis instance running on Windows? Wich OS versión? Commented Aug 27, 2015 at 14:16
  • 1
    This is a running on a Linux box. Commented Aug 31, 2015 at 12:45

1 Answer 1

5
+50

I can give you an example of a working configuration, which we have in our production, no 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>
Sign up to request clarification or add additional context in comments.

1 Comment

I'm not really sure why, but that works! It has to be the ssl=false flag. I had been setting it to true based on some other documentation I found on another error I was receiving. Doh! Now if I could figure out how to get this to run with Sentinels...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.