lua tcp socket queued connect timed out

2019-10-16 10:03:13
收藏数:0
阅读数:181
评论数:9

各位的大佬,lua resty request 会发生 lua tcp socket queued connect timed out错误,什么原因

GUAC.list_active_connections_request = function(host, data_source, token)
    ngx.log(ngx.DEBUG, 'guac_host :', guac_host, "token : ", token)
    api_uri = string.format(API_ACTIVE_CONNECTION, data_source);
    url = string.format("http://%s/%s?token=%s", host, api_uri, token)
    ngx.log(ngx.DEBUG, 'list_active_connections_request :', url, "token : ", token)
    local req_opts = {
        timeouts = GUAC.REQ_TIMEOUTS
    }    
    local response, err = requests.request("GET", url, req_opts)

    if not response then
        ngx.log(ngx.ERR, err)
        return nil
    end
    local res_status_code = response.status_code
    local response_body_raw = response:body()
    if res_status_code ~= 200 then
        ngx.log(ngx.ERR, "list_tunnels_request:" .. res_status_code .. "res_body" .. response_body_raw)
        return nil
    end
    -- return res_raw
    local res_body_json = cjson.decode(response_body_raw)
    return res_body_json
end
horan
horan

你可以具体描述下你用到的代码,和你请求的地址,有可能是 socket 连接数慢了

2019-10-15 23:34:58
flp
flp
local requests = require("resty.requests")

local req_opts = {
        timeouts = GUAC.REQ_TIMEOUTS
    }    
    local response, err = requests.request("GET", url, req_opts)

    if not response then
        ngx.log(ngx.ERR, err)
        return nil
    end

    local res_status_code = response.status_code
    local response_body_raw = response:body()
    if res_status_code ~= 200 then
        ngx.log(ngx.ERR, "list_tunnels_request:" .. res_status_code .. "res_body" .. response_body_raw)
        return nil
    end
    -- return res_raw
    local res_body_json = cjson.decode(response_body_raw)
    return res_body_json

这是lua的代码,多次请求才会报错,socket queued connect 连接数在哪里设置

2019-10-16 09:58:51
flp
flp

local requests = require("resty.requests")

local req_opts = { timeouts = GUAC.REQ_TIMEOUTS }

local response, err = requests.request("GET", url, req_opts)

if not response then
    ngx.log(ngx.ERR, err)
    return nil
end


local res_status_code = response.status_code
local response_body_raw = response:body()
if res_status_code ~= 200 then
    ngx.log(ngx.ERR, "list_tunnels_request:" .. res_status_code .. "res_body" .. response_body_raw)
    return nil
end
-- return res_raw
local res_body_json = cjson.decode(response_body_raw)
return res_body_json

这是lua的代码,多次请求才会报错,socket queued connect 连接数在哪里设置

2019-10-16 09:59:20
flp
flp

求助 急急急

2019-10-16 10:17:32
horan
horan

这个很有可能是你访问的对方接口超时了,如果是你自己的服务,你可以改 nginx 的 connect 数试试

2019-10-16 11:02:13
flp
flp

@horan 是lua所在服务器的配置问题吗

2019-10-16 16:31:17
vvv
vvv

是你访问的接口所在服务器的问题

2019-10-16 23:00:51
flp
flp

已经解决,这个问题是lua http库的问题,应该是没有释放tcp连接导致,谢谢大家了

2019-10-17 18:40:26
flp
flp

已经解决,这个问题是lua http库的问题,应该是没有释放tcp连接导致,谢谢大家了

2019-10-17 18:40:34