AspNetCoreRateLimit icon indicating copy to clipboard operation
AspNetCoreRateLimit copied to clipboard

Update to Version 4.0.1

Open ambabaei opened this issue 3 years ago • 7 comments

Dear All ,

i have updated my project using Ratelimit from 3.2.2 to 4.0.1 and i received error "'Unable to resolve service for type 'AspNetCoreRateLimit.IProcessingStrategy' while attempting to activate 'AspNetCoreRateLimit.IpRateLimitMiddleware" , may i have an answer that what has been changed or added to 4.0.1 to made this error happen? shall i register a new services ? 1

ambabaei avatar Jul 20 '21 09:07 ambabaei

https://github.com/stefanprodan/AspNetCoreRateLimit/releases/tag/4.0.0 https://github.com/stefanprodan/AspNetCoreRateLimit/issues/216

cristipufu avatar Jul 20 '21 11:07 cristipufu

Is there any workable example with version 4? Without the proper docs all the release becomes useless because running it together with Redis is quite complicated.

deivydas321 avatar Aug 09 '21 06:08 deivydas321

unfortunately , I am also could not find a useful data from the link which cristi sent , I still had to use the previous version and did not be able to upgrade myself to the newest version .

br

ambabaei avatar Aug 09 '21 08:08 ambabaei

C'mon, it's really not that hard ...

https://github.com/stefanprodan/AspNetCoreRateLimit/blob/master/test/AspNetCoreRateLimit.Demo/Startup.cs#L35 https://github.com/stefanprodan/AspNetCoreRateLimit/wiki/Using-Redis-as-a-distributed-counter-store

cristipufu avatar Aug 09 '21 15:08 cristipufu

@cristipufu I am really curious why in Demo app services.AddMemoryCache(); is not necessary? In my aspnet core 5 project I had to add it to make it work with simple InMemoryRateLimiting. Also in wiki docs it is added...

deivydas321 avatar Aug 10 '21 11:08 deivydas321

https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-5.0

For most apps, IMemoryCache is enabled. For example, calling AddMvc, AddControllersWithViews, AddRazorPages, AddMvcCore().AddRazorViewEngine, and many other Add{Service} methods in ConfigureServices, enables IMemoryCache. For apps that are not calling one of the preceding Add{Service} methods, it may be necessary to call AddMemoryCache in ConfigureServices.

cristipufu avatar Aug 10 '21 12:08 cristipufu

To solve this particular problem I just added the configuration of the RedisCache through the AddStackExchangeRedisCache() method before adding its IConnectionMultiplexer . But I keep receiving some other error that I couldn't figure how to solve at all.

something like this:

            services.AddStackExchangeRedisCache(options =>
            {
                options.ConfigurationOptions = new ConfigurationOptions
                {
                    //silently retry in the background if the Redis connection is temporarily down
                    AbortOnConnectFail = false
                };
                options.Configuration = configuration.GetConnectionString("Redis");
                options.InstanceName = "HubRateLimit";
            });

https://github.com/stefanprodan/AspNetCoreRateLimit/issues/261

luccasmf avatar Oct 07 '21 16:10 luccasmf