Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack Overflow #19

Open
kshitijmjoshi opened this issue May 4, 2021 · 0 comments
Open

Stack Overflow #19

kshitijmjoshi opened this issue May 4, 2021 · 0 comments

Comments

@kshitijmjoshi
Copy link

kshitijmjoshi commented May 4, 2021

So 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 startup

socket.lua:167: stack overflow

The line 167 is
local phase = get_phase()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant