Skip to content

setSession to nil in recreateSession action to avoid unnecessary CloseSession #700

Merged
magiconair merged 1 commit intogopcua:mainfrom
mvandergrift:libremfg-clear-local-session-on-recreate
Dec 7, 2023
Merged

setSession to nil in recreateSession action to avoid unnecessary CloseSession #700
magiconair merged 1 commit intogopcua:mainfrom
mvandergrift:libremfg-clear-local-session-on-recreate

Conversation

@mvandergrift
Copy link
Copy Markdown
Contributor

In the client.go monitor loop, the recreateSession action builds a new session on the assumption that the server is no longer holding the previous. It does not clear the value of the Client's atomicSession, which leads to CloseSession being called in ActivateSession even if there are no old sessions on the server to be removed.

This behavior is referenced in issue #673.

…ssion.

In the client.go monitor loop, the recreateSession action builds a new session on the assumption that the server is no longer holding the previous. It does not clear the value of atomicSession, which leads to CloseSession being called in ActivateSession even if there are no old sessions to be removed.

This behvior was referenced in issue gopcua#673.
Copy link
Copy Markdown
Contributor

@magiconair magiconair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good catch and I agree. I hope this fixes the issue in #673

@magiconair
Copy link
Copy Markdown
Contributor

I'm going to cut a new release once this is merged. @law-dwg could you maybe test if this fixes your problem as well?

@magiconair magiconair merged commit 7cf7173 into gopcua:main Dec 7, 2023
@magiconair magiconair added this to the v0.5.3 milestone Dec 7, 2023
@magiconair
Copy link
Copy Markdown
Contributor

Released v0.5.3

@mvandergrift mvandergrift deleted the libremfg-clear-local-session-on-recreate branch December 8, 2023 00:56
@law-dwg
Copy link
Copy Markdown

law-dwg commented Dec 8, 2023

Works from my side, thanks!

@magiconair
Copy link
Copy Markdown
Contributor

Awesome!!! Thank you very much both @mvandergrift and @law-dwg

skartikey added a commit to skartikey/opcua that referenced this pull request Apr 13, 2026
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 gopcua#700. The session object is
still held by the local variable and gets re-set inside the callback.

Fixes gopcua#854
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants