Skip to content

Commit

Permalink
Fix elasticsearch connections over SSL.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed May 14, 2018
1 parent dcaa544 commit a201220
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/api-umbrella/utils/elasticsearch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ function _M.query(path, options)
end

local connect_ok, connect_err = httpc:connect(server["host"], server["port"])
if connect_err then
if not connect_ok then
httpc:close()
return nil, "elasticsearch connect error: " .. (connect_err or "")
end

if server["scheme"] == "https" then
local ssl_ok, ssl_err = httpc:ssl_handshake(nil, server["host"], true)
if not ssl_ok then
httpc:close()
return nil, "elasticsearch ssl handshake error: " .. (ssl_err or "")
end
end

local res, err = httpc:request(options)
if err then
httpc:close()
Expand All @@ -49,6 +57,7 @@ function _M.query(path, options)
httpc:close()
return nil, "elasticsearch read body error: " .. (body_err or "")
end
res["body"] = body

local keepalive_ok, keepalive_err = httpc:set_keepalive()
if not keepalive_ok then
Expand Down

0 comments on commit a201220

Please sign in to comment.