From 09c6c70a78e7ca3d8874bbe1c139294e8ae036bd Mon Sep 17 00:00:00 2001 From: skartikey <1942366+skartikey@users.noreply.github.com> Date: Mon, 13 Apr 2026 14:56:17 +0100 Subject: [PATCH] fix restoreSession closing the session it just re-activated During reconnect, the restoreSession path calls ActivateSession with the existing session. ActivateSession's internal callback always calls CloseSession before setting the new session. Since the old and new session are the same object, this sends CloseSessionRequest with DeleteSubscriptions: true, destroying all subscriptions on the server. Clear the session reference before calling ActivateSession, matching the fix applied to recreateSession in #700. The session object is still held by the local variable and gets re-set inside the callback. Fixes #854 --- client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client.go b/client.go index 4dee9d49e..a3cd1d23d 100644 --- a/client.go +++ b/client.go @@ -430,6 +430,10 @@ func (c *Client) monitor(ctx context.Context) { continue } + // clear the session from the client to prevent + // ActivateSession from closing it via CloseSession + c.setSession(nil) + dlog.Printf("trying to restore session") if err := c.ActivateSession(ctx, s); err != nil { dlog.Printf("restore session failed: %v", err)