Skip to content

bug: limit-req in consumer is not work for grpc-proxy #1646

Description

@seans2s

Issue description

For grpc-proxy:
when I add limit-req into service, it works fine and return rejected_code as wish.
but when I add limit-req into consumer, it acts just like there is no limit-req.

For httpbin proxy(normal http 1.1 , not grpc proxy.):
when I add limit-req into consumer, it works fine and return rejected_code as wish.

Environment

  • apisix version (cmd: apisix version): 1.3
  • OS: centos, docker

Minimal test code / Steps to reproduce the issue

  1. add consumer
curl http://127.0.0.1:9080/apisix/admin/consumers/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "username": "jwt1",
    "plugins": {
        "jwt-auth": {
            "key": "ak",
            "secret": "sk"
        },
        "limit-req": {
            "rate": 1,
            "burst": 0,
            "rejected_code": 429,
            "key": "remote_addr"
        }
    }
}'
  1. add grpc route
//172.21.144.41:50051 is grpc server. you may need to change it to 127.0.0.1:50051
curl http://127.0.0.1:9080/apisix/admin/upstreams/8 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "type": "roundrobin",
        "nodes": {
            "172.21.144.41:50051": 1  
        }
}'
curl http://127.0.0.1:9080/apisix/admin/services/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "upstream_id": 8
}'
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "methods": ["POST", "GET"],
    "uri": "/helloworld.Greeter/SayHello",
    "service_protocol": "grpc",
    "service_id": 1,
    "plugins": {
        "jwt-auth": {}
    }
}'
  1. fetch jwt token
curl http://127.0.0.1:9080/apisix/plugin/jwt/sign\?key\=ak
  1. request service
grpcurl -v -insecure -import-path ./proto/  -proto helloworld.proto  \
    -d '{"name":"apisix"}' -H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJhayIsImV4cCI6MTU5MTI2NjExNX0.Ok07taBf2KglnuqHtMWwxqNJ6CBo451uJmsMHkFblGc' 127.0.0.1:9443 helloworld.Greeter.SayHello

What's the actual result? (including assertion message & call stack if applicable) rejected_code is not returned as wish. it acts just like there is not limit-req.

What's the expected result?

limit-req should work just like normal http request.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions