diff --git a/kong/clustering/rpc/manager.lua b/kong/clustering/rpc/manager.lua index ea5c4f5a2822..44b166f440ed 100644 --- a/kong/clustering/rpc/manager.lua +++ b/kong/clustering/rpc/manager.lua @@ -559,6 +559,7 @@ function _M:connect(premature, node_id, host, path, cert, key) ::err:: if not exiting() then + c:close() self:try_connect(reconnection_delay) end end diff --git a/kong/clustering/utils.lua b/kong/clustering/utils.lua index ee34e7dce2e4..bebef2f2daf5 100644 --- a/kong/clustering/utils.lua +++ b/kong/clustering/utils.lua @@ -106,6 +106,7 @@ function _M.connect_cp(dp, endpoint, protocols) local ok, err = c:connect(uri, opts) if not ok then + c:close() return nil, uri, err end