From bdf1d20f4ec79cbc7be7b552121de0ee55456af3 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 18 Jan 2020 15:39:26 +0000 Subject: [PATCH] extract an ip that can be advertised in embedded nats --- broker/nats/nats.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/broker/nats/nats.go b/broker/nats/nats.go index 44d66216..67833092 100644 --- a/broker/nats/nats.go +++ b/broker/nats/nats.go @@ -120,7 +120,13 @@ func (n *natsBroker) serve(exit chan bool) error { // with no address we just default it // this is a local client address if len(n.addrs) == 0 { - host = "127.0.0.1" + // find an advertiseable ip + if h, err := addr.Extract(""); err != nil { + host = "127.0.0.1" + } else { + host = h + } + port = -1 local = true } else {