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

bug: rejected_msg not working in limit-count plugin #5107

Closed
tinpad opened this issue Sep 21, 2021 · 3 comments
Closed

bug: rejected_msg not working in limit-count plugin #5107

tinpad opened this issue Sep 21, 2021 · 3 comments

Comments

@tinpad
Copy link

tinpad commented Sep 21, 2021

Issue description

I am using below request to setup limit-count as global rule.

curl http://127.0.0.1:9080/apisix/admin/global_rules/111 -H 'X-API-KEY: xxxxxxxxxxxxxxxxxxxx' -X PUT -d '
{
"plugins": {
"limit-count": {
"time_window": 60,
"policy": "local",
"count": 10,
"key": "remote_addr",
"rejected_code": 429,
"rejected_msg" : "{"message":"Request Limit Exceeded"}"
}
}
}'
When I hit the below route and the count exceeds the count 10 -

http://127.0.0.1:9080/order/list?pageSize=10

I am getting 429 but not getting the response in json format as mentioned in the above route.
I am getting following html content -

<title>429 Too Many Requests</title>

429 Too Many Requests


openresty

Environment

  • apisix version (cmd: apisix version): 2.8
  • OS (cmd: uname -a): 20.04.1-Ubuntu
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V): openresty/1.19.3.2
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): 3.4.0
  • apisix-dashboard version, if have: NA
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version): 3.4.0

Steps to reproduce

as mentioned above, if we exceed the request count more than 10

Actual result

<title>429 Too Many Requests</title>

429 Too Many Requests


openresty

Error log

2021/09/21 13:57:03 [warn] 2926#2926: *85612 [lua] plugin.lua:658: run_plugin(): limit-count exits with http status code 429, client: 127.0.0.1, server: _, request: "GET /order/list?pageSize=10 HTTP/1.1", host: "127.0.0.1:9080"

Expected result

{"message":"Request Limit Exceeded"}

@tokers
Copy link
Contributor

tokers commented Sep 21, 2021

@tinpad Have you ever tried to check out the route object by using the GET API?

@tinpad
Copy link
Author

tinpad commented Sep 21, 2021

@tokers I am getting below json with get api

{
"node": {
"dir": true,
"nodes": [
{
"createdIndex": 1989,
"key": "/apisix/global_rules/111",
"modifiedIndex": 3019,
"value": {
"plugins": {
"limit-count": {
"key": "remote_addr",
"rejected_code": 429,
"redis_database": 0,
"policy": "local",
"time_window": 60,
"rejected_msg": "{"message":"Request Limit Exceeded"}",
"count": 10
},
"uri-blocker": {
"block_rules": [
"script.bat",
"script.sh",
"script.exe"
],
"rejected_code": 403
},
"http-logger": {
"retry_delay": 1,
"timeout": 3,
"uri": "http://192.168.1.2:8060/logger/log",
"auth_header": "",
"buffer_duration": 60,
"batch_max_size": 1000,
"include_req_body": false,
"inactive_timeout": 5,
"max_retry_count": 0,
"name": "http logger",
"concat_method": "json"
},
"basic-auth": {},
"prometheus": {
"prefer_name": false
}
},
"id": "111",
"update_time": 1632221711,
"create_time": 1631798886
}
}
],
"key": "/apisix/global_rules"
},
"count": "3",
"action": "get"
}

@spacewander
Copy link
Member

The rejected_msg is added in 2.9: #4808
So APISIX 2.8 doesn't support it.

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

3 participants