From 97feadcae36b9679b603a40f854a6701e7965ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B4=81=E4=BF=8A=EF=BC=88Jack=EF=BC=89?= Date: Fri, 19 Jan 2024 14:04:44 +0800 Subject: [PATCH] fix:https://github.com/opensearch-project/opensearch-go/issues/458 --- opensearchtransport/discovery.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/opensearchtransport/discovery.go b/opensearchtransport/discovery.go index 94a8947be..c2abd42bd 100644 --- a/opensearchtransport/discovery.go +++ b/opensearchtransport/discovery.go @@ -194,8 +194,10 @@ func (c *Client) getNodeURL(node nodeInfo, scheme string) *url.URL { host = strings.Split(addrs[0], ":")[0] } } - - port = ports[len(ports)-1] + if len(port) == 0 { + port = ports[len(ports)-1] + } + u := &url.URL{ Scheme: scheme, Host: net.JoinHostPort(host, port),