wxbty opened a new issue, #9661:
URL: https://github.com/apache/apisix/issues/9661
### Current Behavior
When adding stream_routes for the redis protocol, if the limit-conn plugin
is used, an error will be reported
### Expected Behavior
created route successfully
### Error Logs
2023/06/14 17:35:07 [error] 30109#30109: *773 failed to run log_by_lua*:
/opt/linyao/apisix/apisix/plugins/limit-conn/init.lua:123: attempt to perform
arithmetic on field 'request_time' (a nil value)
stack traceback:
/opt/linyao/apisix/apisix/plugins/limit-conn/init.lua:123: in function
'phase_func'
/opt/linyao/apisix/apisix/plugin.lua:1134: in function 'run_plugin'
/opt/linyao/apisix/apisix/init.lua:1083: in function 'stream_log_phase'
log_by_lua(nginx.conf:108):2: in main chunk while prereading client
data, client: 127.0.0.1, server: 0.0.0.0:9100
2023/06/14 17:35:12 [error] 30113#30113: *2961 stream [lua] init.lua:106:
phase_func(): decrease_to record the connection leaving request while
prereading client data, client: 127.0.0.1, server: 0.0.0.0:9100
2023/06/14 17:35:12 [error] 30113#30113: *2961 failed to run log_by_lua*:
/opt/linyao/apisix/apisix/plugins/limit-conn/init.lua:123: attempt to perform
arithmetic on field 'request_time' (a nil value)
stack traceback:
/opt/linyao/apisix/apisix/plugins/limit-conn/init.lua:123: in function
'phase_func'
/opt/linyao/apisix/apisix/plugin.lua:1134: in function 'run_plugin'
/opt/linyao/apisix/apisix/init.lua:1083: in function 'stream_log_phase'
log_by_lua(nginx.conf:108):2: in main chunk while prereading client
data, client: 127.0.0.1, server: 0.0.0.0:9100
### Steps to Reproduce
1. Tcp dynamic proxy uses redis protocol
2. Create a route with the limit-conn plugin as follow
curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"limit-conn": {
"conn": 5,
"burst": 0,
"default_conn_delay": 0.1,
"rejected_code": 503,
"key_type": "var",
"key": "remote_addr"
}
},
"upstream": {
"type": "none",
"nodes": {
"127.0.0.1:6379": 1
}
},
"protocol": {
"name": "redis"
}
}
'
3. Check the error log and find the error message
### Environment
APISIX version (run apisix version): master latest
Operating system (run uname -a): centos7
OpenResty / Nginx version (run openresty -V or nginx -V): openresty/1.21.4.1
etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
3.5.0
APISIX Dashboard version, if relevant:
Plugin runner version, for issues related to plugin runners:
LuaRocks version, for installation issues (run luarocks --version):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]