I have the following piece of code in the init_by_lua_file in the http context
local http = require "resty.http"
local httpc = http.newCoSocket()
where I have added
function _M.newCoSocket()
local sock = socket.tcp() -- similar to ngx.socket.tcp().
return setmetatable({.
sock = sock.
}, {__index = _M}).
end.
function _M:connect(host, port)
local ok, err = self.sock:connect(host, port)
if not ok then
return nil, err
end
local times, err = self.sock:getreusedtimes() -- cosocket API
if not times then
return nil, err
elseif times == 0 then
-- handle connection
end
end
to the http.lua file.
I get the following error on the startup
socket.lua:167: stack overflow
The line 167 is
local phase = get_phase()