Giter Club home page Giter Club logo

Comments (4)

oatsoda avatar oatsoda commented on May 7, 2024

Add NuGet for:

Microsoft.Extensions.Caching.Redis

In your Web App startup, add

   services.AddDistributedRedisCache(options =>
   {
       options.Configuration = "your redis connection string"; // e.g. contoso5.redis.cache.windows.net,abortConnect=false,ssl=true,password=...
       options.InstanceName = "master";
   });'

This will ensure that the Redis implementation of IDistributedCache is registered into your DI container.

Then register AspNetCoreRateLimit as per the wiki:

   // Bind Settings and Policy
   services.Configure<IpRateLimitOptions>(Configuration.GetSection("IpRateLimiting"));
   services.Configure<IpRateLimitPolicies>(Configuration.GetSection("IpRateLimitPolicies"));

   // inject counter and rules stores
   services.AddSingleton<IIpPolicyStore, DistributedCacheIpPolicyStore>();
   services.AddSingleton<IRateLimitCounterStore, DistributedCacheRateLimitCounterStore>();

Don't forget to call app.UseIpRateLimiting() in your Web App startup too.

And don't forget to add all the config into your appSettings.json

from aspnetcoreratelimit.

MajidDehnamaki avatar MajidDehnamaki commented on May 7, 2024

@oatsoda
hi
i do this but show me this error:
RedisConnectionException: No connection is available to service this operation: EVAL; SocketFailure on localhost:6379/Subscription

from aspnetcoreratelimit.

oatsoda avatar oatsoda commented on May 7, 2024

@MajidDehnamaki Perhaps your Redis connection string is wrong? Or some sort of Firewall/Connectivity issue between your App Service (I assume you are using a standard Azure App Service?) and your Redis.

It doesn't sound like an AspNetCoreRateLimit issue...

You might want to test out using the IDistributedCache interface directly and once you get that working, then turn on the rate limiting.

from aspnetcoreratelimit.

manisha201301 avatar manisha201301 commented on May 7, 2024

Also, if you are using AspNetCoreRateLimit.Redis package with services.UseRedisRateLimiting() then you don't need to add the policy stores as they are added internally for you.

from aspnetcoreratelimit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.