Open Closed

Using Redis with a Load Balancer #6142


0
cmthomps created

We were having trouble with getting aspnetzero MVC/jQuery to work with redis behind a load balancer. We couldn't get it to work unless we used sticky sessions. We think we finally figured it out. We had to add the following code to persist the keys to redis in the startup.cs class:

if (_appConfiguration["Abp:RedisCache:PersistKeysToRedis"] != null && bool.Parse(_appConfiguration["Abp:RedisCache:PersistKeysToRedis"]))
            {
                var redis = ConnectionMultiplexer.Connect(_appConfiguration["Abp:RedisCache:ConnectionString"]);
                services.AddDataProtection()
                    .PersistKeysToRedis(redis, "DataProtection-Keys");
            }
            else
            {
                services.AddDataProtection().DisableAutomaticKeyGeneration();
            }

Is that the correct solution? If so, should I add it as an issue in github?


2 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @cmthomps

    We haven't tried using Redis with AspNet Zero using a load balancer. If it works for you, you can use this solution. You don't have to create an issue on AspNet Zero repository.

    If someone else faces the same problem, we can offer your solution.

  • 0
    vuca created

    Hi @cmthomps,

    We use asp.net zero (version 5.4) with loadbalancer A10 - but only use persit source mode only. Can we use without persit source? They are

    Thanks!