From e84a8fdfa82cbfae114a58879145019fd743368d Mon Sep 17 00:00:00 2001 From: Zohaib Sibte Hassan Date: Mon, 27 Nov 2023 10:28:03 -0800 Subject: [PATCH] Fixing issue on client disconnect killing server --- cfg/config.go | 2 +- stream/embedded_nats.go | 2 -- stream/nats.go | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cfg/config.go b/cfg/config.go index 5525922..20d3fce 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -159,7 +159,7 @@ var Config = &Configuration{ SeedFile: "", CredsPassword: "", CredsUser: "", - BindAddress: "0.0.0.0:4222", + BindAddress: ":-1", ConnectRetries: 5, ReconnectWaitSeconds: 2, }, diff --git a/stream/embedded_nats.go b/stream/embedded_nats.go index bf2ee8d..4532c71 100644 --- a/stream/embedded_nats.go +++ b/stream/embedded_nats.go @@ -77,8 +77,6 @@ func startEmbeddedServer(nodeName string) (*embeddedNats, error) { opts.Cluster.ListenStr = *cfg.ClusterAddrFlag opts.Cluster.Host = host opts.Cluster.Port = port - opts.LeafNode.Host = host - opts.LeafNode.Port = port + 1 } if *cfg.LeafServerFlag != "" { diff --git a/stream/nats.go b/stream/nats.go index afc8734..c470d4d 100644 --- a/stream/nats.go +++ b/stream/nats.go @@ -96,7 +96,7 @@ func setupConnOptions() []nats.Option { nats.ReconnectWait(time.Duration(cfg.Config.NATS.ReconnectWaitSeconds) * time.Second), nats.MaxReconnects(cfg.Config.NATS.ConnectRetries), nats.ClosedHandler(func(nc *nats.Conn) { - log.Fatal(). + log.Error(). Err(nc.LastError()). Msg("NATS client exiting") }),