You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/08/23 01:56:00 UTC
[GitHub] [apisix] zwjzxh520 opened a new issue #4869: 自己写插件的时候,遇到了问题:API disabled in the context of log_by_lua
zwjzxh520 opened a new issue #4869:
URL: https://github.com/apache/apisix/issues/4869
### Issue description
依照 api-breaker 自己编写了一个插件,将计数器放到redis中,但是发现运行的时候一直报以下错误:
```
2021/08/20 16:46:14 [error] 45#45: *2067 failed to run log_by_lua*: /usr/local/apisix/apisix/patch.lua:315: API disabled in the context of log_by_lua*
stack traceback:
[C]: in function 'original_tcp'
/usr/local/apisix/apisix/patch.lua:315: in function 'tcp'
/usr/local/openresty/lualib/resty/redis.lua:63: in function 'redis_new'
/usr/local/apisix/apisix/plugins/sdp-api-breaker.lua:131: in function 'new_redis'
/usr/local/apisix/apisix/plugins/sdp-api-breaker.lua:239: in function 'phase_func'
/usr/local/apisix/apisix/plugin.lua:679: in function 'common_phase'
/usr/local/apisix/apisix/init.lua:681: in function 'http_log_phase'
```
报错相关代码如下:

```lua
function _M.log(conf, ctx)
local redis_util, err = new_redis(conf)
if redis_util == nil then
core.log.error("redis init failed at _M.log, err: ", err)
return
end
local unhealthy_key = gen_unhealthy_key(ctx)
local healthy_key = gen_healthy_key(ctx)
local upstream_status = core.response.get_upstream_status(ctx)
```
请帮忙找找解决办法,谢谢大家了~
### Environment
- apisix version (cmd: `apisix version`): **2.8**
- OS (cmd: `uname -a`): **alpine docker**
- OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): **nginx version: openresty/1.19.3.1**
- 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:
- luarocks version, if the issue is about installation (cmd: `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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4869: 自己写插件的时候,遇到了问题:API disabled in the context of log_by_lua
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4869:
URL: https://github.com/apache/apisix/issues/4869#issuecomment-903396043
`ngx.socket.tcp` doesn't support log_by_lua: https://github.com/openresty/lua-nginx-module#ngxsockettcp
You may use `ngx.timer.at` to work around it.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #4869: 自己写插件的时候,遇到了问题:API disabled in the context of log_by_lua
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #4869:
URL: https://github.com/apache/apisix/issues/4869
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org