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

Connect Pool Not Work #320

Open
JamesSunXX opened this issue Aug 23, 2024 · 0 comments
Open

Connect Pool Not Work #320

JamesSunXX opened this issue Aug 23, 2024 · 0 comments

Comments

@JamesSunXX
Copy link

JamesSunXX commented Aug 23, 2024

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