ledgetech / ledgetech/lua-resty-http
closed error when sending request
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 2.1k
- Forks
- 630
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I have an issue while trying to send HTTP POST request to remote host. I get "closed" error message and I can't understand what is the problem.
This is my code:
local httpc = http.new()
httpc:set_timeout(5000)
local request_body = "id=myId¶m2=key2¶m3=key3"
local req_len = string.len(request_body)
local ok, err = httpc:connect({
scheme = "https",
host = "100.0.0.0",
port = 443,
ssl_verify = false
})
if not ok or err then
ngx.log(ngx.NOTICE, "Error while connecting to remote host " .. err)
return ngx.exit(500)
end
--- Here I get closed error message, response is nil
local response, err = httpc:request({
path = '/api/client',
method = 'POST',
body = request_body,
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = req_len,
["Host"] = "100.0.0.0"
}
})
if err then
ngx.log(ngx.NOTICE, "Error while sending req remote host " .. err)
return ngx.exit(500)
end
if not response or response["status"] ~= 200 or not response["body"] then
ngx.log(ngx.NOTICE, "Failed to send req to remote host " .. err)
return ngx.exit(500)
end
the "connect" succeeded but when I execute the request command I got the error.
I verified that the content-length is correct.
I also tried to use requesturi but got the same error.
The request body is form data.
What do I miss?
Thank you,
Barak.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the http.new(), connect(), and request() calls shown in the issue, then compare their usage with the lua-resty-http documentation and request implementation. Reproduce the HTTPS POST and determine why request() returns "closed"; the issue does not define a code change, test, or other concrete completion condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100