Skip to content
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

Rate limiter not working #1598

Closed
ks1990cn opened this issue Sep 11, 2022 · 2 comments
Closed

Rate limiter not working #1598

ks1990cn opened this issue Sep 11, 2022 · 2 comments
Assignees

Comments

@ks1990cn
Copy link
Contributor

This is my Ocelot.Json file, rate limiter is not working. Can any one tell me any thing else I need to add on?

{
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:49977",
    "RateLimitOptions": {
      "DisableRateLimitHeaders": false,
      "QuotaExceededMessage": "Customize Tips!",
      "HttpStatusCode": 999,
      "ClientIdHeader": "Test"
    }
  },
  "ReRoutes": [
    //This is for IMDB API
    {
      "UpstreamPathTemplate": "/GetMovie",
      "UpstreamHttpMethod": [
        "Get"
      ],
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 25158
        }
      ],
      "DownstreamPathTemplate": "/GetMovie"
    },
    //This is to get from WeatherForecast Microservice
    {
      "UpstreamPathTemplate": "/wf",
      "UpstreamHttpMethod": [
        "Get"
      ],
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 42446
        }
      ],
      "DownstreamPathTemplate": "/WeatherForecast"
    }
  ]
}
@veyxov
Copy link

veyxov commented Dec 14, 2022

You need to add a RateLimitOptions field to your routes.

      "RateLimitOptions": {
        "ClientWhitelist": [],
        "Period": "10s",
        "EnableRateLimiting": true,
        "PeriodTimespan": 10,
        "Limit": 10
      }

source: https://ocelot.readthedocs.io/en/latest/features/ratelimiting.html

@ks1990cn
Copy link
Contributor Author

ks1990cn commented Oct 3, 2023

It worked.. closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants