-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Rate Limiting feature doesn't work when use DistributedCache #609
Comments
I have found out the bug. The DistributedCacheRateLimitCounterHanlder.Get method will be called, when the RedisCache is enabled. Within the method, call JsonConvert.DeserializeObject funtion to load RateLimitCounter instance from json string. But both Timestamp and TotalRequests properties are readonly of the RateLimitCounter struct. So to fix this bug, should apply the JsonConstructorAttribute to RateLimitCounter's constructor and rename totalRequest parameter to totalRequests. [JsonConstructor]
public RateLimitCounter(DateTime timestamp, long totalRequests)
{
Timestamp = timestamp;
TotalRequests = totalRequests;
} |
@rocgao thanks for this issue and the fix. I really appreciate it. I will merge this into NuGet package ASAP. |
fixed in 11.0.3, any problems let me know |
@rocgao add me with wechat geffzhang |
@rocgao @geffzhang Regarding the user scenario with RedisCache... |
Expected Behavior
External http request should be blocked when quota exceeded.
Actual Behavior
External http request was forwarded to downstream servers always.
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: