stefanprodan / AspNetCoreRateLimit

ASP.NET Core rate limiting middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object reference not set to an instance of an object

bingxueyinlian opened this issue · comments

  • After running for a period of time, the following exceptions will appear
: Microsoft.AspNetCore.Server.Kestrel[13] 
      Connection id "0HME5PCQA5O1V", Request id "0HME5PCQA5O1V:00000002": An unhandled exception was thrown by the application. 
      System.NullReferenceException: Object reference not set to an instance of an object. 
         at AspNetCoreRateLimit.RateLimitProcessor.<>c__DisplayClass4_0.<GetMatchingRules>b__11(RateLimitRule r) in C:\Users\User\Documents\Github\AspNetCoreRateLimit\src\AspNetCoreRateLimit\Core\RateLimitProcessor.cs:line 109 
         at System.Linq.Enumerable.WhereListIterator`1.MoveNext() 
         at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) 
         at AspNetCoreRateLimit.RateLimitProcessor.GetMatchingRules(ClientRequestIdentity identity, List`1 rules) in C:\Users\User\Documents\Github\AspNetCoreRateLimit\src\AspNetCoreRateLimit\Core\RateLimitProcessor.cs:line 110 
         at AspNetCoreRateLimit.IpRateLimitProcessor.GetMatchingRulesAsync(ClientRequestIdentity identity, CancellationToken cancellationToken) in C:\Users\User\Documents\Github\AspNetCoreRateLimit\src\AspNetCoreRateLimit\Core\IpRateLimitProcessor.cs:line 47 
         at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in C:\Users\User\Documents\Github\AspNetCoreRateLimit\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 49 
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) 
  • the runtime environment is : .NET 5 + docker + k8s

  • No error is reported after restarting .