Skip to content

Stack Overflow #19

Description

@kshitijmjoshi

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()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions