Skip to content

Commit

Permalink
setSession to nil when recreating to avoid unncessary call to CloseSe…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
mvandergrift committed Dec 6, 2023
1 parent 1782ad0 commit bc2e844
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ func (c *Client) monitor(ctx context.Context) {
c.setState(Reconnecting)
// create a new session to replace the previous one

// clear any previous session as we know the server has closed it
// this also prevents any unnecessary calls to CloseSession
c.setSession(nil)

dlog.Printf("trying to recreate session")
s, err := c.CreateSession(ctx, c.cfg.session)
if err != nil {
Expand Down

0 comments on commit bc2e844

Please sign in to comment.