下载了官方的RPM包:
openresty-1.21.4.1-1.el7.x86_64.rpm
openresty-openssl111-1.1.1n-1.el7.x86_64.rpm
openresty-pcre-8.45-1.el7.x86_64.rpm
openresty-zlib-1.2.12-1.el7.x86_64.rpm
使用如下配置:
exit_worker_by_lua_block {
local sock = ngx.socket.tcp()
local port = 80
local ok, err = sock:connect("127.0.0.1", port)
if not ok then
ngx.say("failed to connect: ", err)
return
end
ngx.say("connected: ", ok)
ok, err = sock:close()
ngx.say("close: ", ok, " ", err)
}
错误日志如下:
2022/05/26 17:29:22 [error] 16079#16079: exit_worker_by_lua error: exit_worker_by_lua:2: API disabled in the context of exit_worker_by_lua*
stack traceback:
[C]: in function 'tcp'
exit_worker_by_lua:2: in main chunk