Skip to content

Commit

Permalink
Force localhost
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Santomaggio <[email protected]>
  • Loading branch information
Gsantomaggio committed Jun 19, 2024
1 parent f9c121e commit 1962695
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/stream/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,20 @@ func (c *Client) BrokerLeader(stream string) (*Broker, error) {
if streamMetadata.Leader == nil {
return nil, LeaderNotReady
}

streamMetadata.Leader.advPort = streamMetadata.Leader.Port
streamMetadata.Leader.advHost = streamMetadata.Leader.Host

// see: https://github.com/rabbitmq/rabbitmq-stream-go-client/pull/317
_, err := net.LookupIP(streamMetadata.Leader.Host)
if err != nil {
var dnsError *net.DNSError
if errors.As(err, &dnsError) {
if strings.EqualFold(c.broker.Host, "localhost") {
logs.LogWarn("DNS error: %s, trying to use localhost", dnsError)
logs.LogWarn("Can't lookup the DNS for %s, error: %s. Trying localhost..", streamMetadata.Leader.Host, err)
streamMetadata.Leader.Host = "localhost"
} else {
logs.LogWarn("DNS error: %s")
logs.LogWarn("Can't lookup the DNS for %s, error: %s", streamMetadata.Leader.Host, err)
}
}
}
Expand Down

0 comments on commit 1962695

Please sign in to comment.