lua-resty-http icon indicating copy to clipboard operation
lua-resty-http copied to clipboard

Connect Pool Not Work

Open JamesSunXX opened this issue 1 year ago • 0 comments

local function send_mirror_request(premature, method, url, headers, body)
    local httpc = http.new()
    headers['dev-mirror'] = "1"
    local res, err = httpc:request_uri(url, {
        version = 1.1,
        method = method,
        headers = headers,
        body = body,
	ssl_verify = false,
        keepalive_timeout = 65000,
        keepalive = true,
        keepalive_pool = 200,
    })

    if not res then
        ngx.log(ngx.ERR, "Failed to mirror request: ", err)
        return
    end

    ngx.log(ngx.DEBUG, "response connection:" ..res.headers["Connection"])
    local ok, err = httpc:set_keepalive(65000, 200)
    if not ok then
       ngx.log(ngx.ERR, "failed to set keepalive: ", err)
       return
    end
end

local ok, err = ngx.timer.at(0, send_mirror_request, ngx.var.request_method, mirror_url, headers, body_data)
if not ok then
    ngx.log(ngx.ERR, "Failed to create timer: ", err)
end

recieve log info

[debug] 5868#0: *2873067271 [lua] response connection:keep-alive
[error] 5868#0: *2873067271 [lua] failed to set keepalive: closed, context: ngx.timer

JamesSunXX avatar Aug 23 '24 16:08 JamesSunXX