Skip to content

Commit

Permalink
Merge pull request #552 from gopcua/issue-547-update-namespace-on-rec…
Browse files Browse the repository at this point in the history
…onnect

client: update namespaces on reconnect
  • Loading branch information
magiconair authored Jan 27, 2022
2 parents 10b27a4 + 0264c0e commit 4dee16b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (c *Client) Connect(ctx context.Context) (err error) {
// todo(fs): server. For the sake of simplicity we left the option out but
// todo(fs): see the discussion in https://github.com/gopcua/opcua/pull/512
// todo(fs): and you should find a commit that implements this option.
if err := c.UpdateNamespaces(); err != nil {
if err := c.UpdateNamespacesWithContext(ctx); err != nil {
c.Close()
stats.RecordError(err)

Expand Down Expand Up @@ -387,6 +387,16 @@ func (c *Client) monitor(ctx context.Context) {
continue
}
dlog.Printf("session restored")

// todo(fs): see comment about guarding this with an option in Connect()
dlog.Printf("trying to update namespaces")
if err := c.UpdateNamespacesWithContext(ctx); err != nil {
dlog.Printf("updating namespaces failed: %v", err)
action = createSecureChannel
continue
}
dlog.Printf("namespaces updated")

action = restoreSubscriptions

case recreateSession:
Expand All @@ -408,6 +418,15 @@ func (c *Client) monitor(ctx context.Context) {
}
dlog.Print("session recreated")

// todo(fs): see comment about guarding this with an option in Connect()
dlog.Printf("trying to update namespaces")
if err := c.UpdateNamespacesWithContext(ctx); err != nil {
dlog.Printf("updating namespaces failed: %v", err)
action = createSecureChannel
continue
}
dlog.Printf("namespaces updated")

action = transferSubscriptions

case transferSubscriptions:
Expand Down

0 comments on commit 4dee16b

Please sign in to comment.