From 23ddac33dd568853e098cb6509387fd8b6d1bc8e Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 20 Sep 2024 22:59:31 -0300 Subject: [PATCH] hopefully fix a segfault with broken connections. --- relay.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/relay.go b/relay.go index ca86a1c..1ffb1fe 100644 --- a/relay.go +++ b/relay.go @@ -182,6 +182,10 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error // stop the ticker ticker.Stop() + + // nil the connection + r.Connection = nil + // close all subscriptions r.Subscriptions.Range(func(_ string, sub *Subscription) bool { go sub.Unsub() @@ -520,7 +524,6 @@ func (r *Relay) Close() error { } err := r.Connection.Close() - r.Connection = nil if err != nil { return err }