ngx.socket.tcp can't be used in log phase according to doc. https://github.com/openresty/lua-nginx-module#ngxsockettcp
but I tested and found that lua-resty-mysql, based in ngx.socket.tcp can be used in log phase, why ?
ngx.socket.tcp can't be used in log phase according to doc. https://github.com/openresty/lua-nginx-module#ngxsockettcp
but I tested and found that lua-resty-mysql, based in ngx.socket.tcp can be used in log phase, why ?
Your test wrong.
Here is small test setup
How to run:
docker-compose up
Figure out nginx port:
docker ps
Test:
curl 127.0.0.1:<port>
And here is the proof:
nginx_1 | 2018/07/02 09:03:05 [error] 7#7: *1 failed to run log_by_lua*: /usr/local/openresty/lualib/resty/mysql.lua:520: API disabled in the context of log_by_lua*
nginx_1 | stack traceback:
nginx_1 | [C]: in function 'tcp'
nginx_1 | /usr/local/openresty/lualib/resty/mysql.lua:520: in function 'new'
nginx_1 | log_by_lua(nginx.conf:61):3: in function <log_by_lua(nginx.conf:61):1> while logging request, client: 192.168.112.1, server: , request: "GET / HTTP/1.1", host: "127.0.0.1:33195"