Open Tyslan opened 2 months ago
For now the following work around seems to work for me:
I'll check if the node I want to subscribe to is a node that has a value attribute. If this check returns an error I do not add it to the MonitoredItemCreateRequest
miRequests := make([]*ua.MonitoredItemCreateRequest, 0, len(nodeIDs))
for i, nodeID := range nodeIDs {
nid, err := ua.ParseNodeID(nodeID)
if err != nil {
slog.Error("Failed to parse nodeID.", "error", err)
continue
}
node := client.Node(nid)
if _, err := node.Attribute(ctx, ua.AttributeIDValue); err != nil {
slog.Error("Node is not a value node.", "nodeID", nodeID, "error", err)
} else {
miRequests = append(miRequests, valueRequest(nid, uint32(i+1)))
slog.Info("Node exists.", "nodeID", nodeID)
}
}
res, err := subscription.Monitor(ctx, ua.TimestampsToReturnBoth, miRequests...)
I'm unsure if this is the proper way of working, but at least it fixes my problem for now.
After auto reconnect it seems like subscriptions don't send DataChangeNotification anymore.
I was able to reproduce this issue by changing the subscribe example a little:
Initially I receive the DatachangeNotifications of the existing node. If I break the connection between the OPC server and the client, I can see the the reconnection flow is followed. But in the end I see "no subscriptions to resume" in the logs and I receive no longer DatachangeNotifications.
If you do the same with only existing nodes om the servers, you see log messages like "resuming 1 subscriptions" and "resumed 1 subscriptions"