Reputation: 8657
I have a demo ASP.NET app with the session store configured to use a single Redis master node using the Microsoft.Web.Redis.RedisSessionStateProvider nuget (config below).
As a next step I would like to change my Redis store to be high availability by adding slave and sentinel nodes. Question (1): does the RedisSessionStateProvider support this, and (2) if so, how do I configure RedisSessionStateProvider to refer to sentinel nodes.
<sessionState mode="Custom" customProvider="RedisProvider" timeout="240" cookieless="UseCookies" cookieName="ASP.NET_SessionId" useHostingIdentity="true">
<providers>
<add name="RedisProvider"
type="Microsoft.Web.Redis.RedisSessionStateProvider, Microsoft.Web.RedisSessionStateProvider"
host="127.0.0.1"
port="6379"
accessKey=""
ssl="false" />
</providers>
</sessionState>
Upvotes: 2
Views: 1442
Reputation: 701
To answer your question quickly... remove host, port, accessKey, and ssl attributes from the provider config and add connectionString. Enter the correct connection string information for your case: ie - "192.168.1.10:6379,192.168.1.11:6379,192.168.1.12:6379,ssl=false,password=My_Super_Secret_Password". Since you are using a cluster configuration all node passwords have to be the same for this to work correctly. You also need to provide the applicationName attribute like applicationName="TestApp" so your web.config should look something like the following:
<sessionState mode="Custom" cookieName="_web.ss" customProvider="RedisSessionStateProvider" cookieless="false" timeout="10080">
<providers>
<clear />
<add name="RedisSessionStateProvider"
type="Microsoft.Web.Redis.RedisSessionStateProvider"
applicationName="TestApp"
connectionString="192.168.1.10:6379,192.168.1.11:6379,192.168.1.12:6379,ssl=false,password=My_Super_Secret_Password" />
</providers>
</sessionState>
Hope this help :)
Upvotes: 3