SDK Client-Server scenario: Either Subscription is not updated or subscriber misses the update

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Sandmann
Jr. Member
Jr. Member
Posts: 2
Joined: 07 Dec 2012, 17:02

SDK Client-Server scenario: Either Subscription is not updated or subscriber misses the update

Post by Sandmann »

Hi,

after a workshop (introduction to OPC UA using Unified Automation SDK) last month we're currently doing some basic prototyping based on SDK.

We already prepared a Client subscribing some values.
Now we're trying to setup a server to supply these values. Basically this is already working as well. Except it works only for short time. Afterwards the server still updates the value, but the subscribing client no longer gets notified.

When using UaExpert the value still gets updated.
By the way: It's a boolean value.

Here is an excerpt of the client:

Code: Select all

      _subscription = new Subscription(Session);
      _subscription.PublishingInterval = 1;
      _subscription.PublishingEnabled = true;
      _subscription.Lifetime = Session.SessionTimeout;
      _subscription.MaxKeepAliveTime = Session.WatchdogTimeout / 2;
      _subscription.DataChanged += new DataChangedEventHandler(LineControllerSubscriptionDataChanged);
      _subscription.StatusChanged += new SubscriptionStatusChangedEventHandler(LineControllerSubscriptionStatusChanged);
      _subscription.MaxNotificationsPerPublish = 0;

      _subscription.MissingSequenceNumber += new MissingSequenceNumberEventHandler(TestMissingSequence);
      _subscription.NewEvents += new NewEventsEventHandler(TestNewEvents);
      _subscription.NotificationMessageReceived += new NotificationMessageReceivedEventHandler(TestNotificationMessage);


      _subscription.Create();


      var monitoredItems = new List<MonitoredItem>();
      _linecontrollerWriteMonitoredItem = new DataMonitoredItem(NodeId.Parse(Identifier.LcWriteNodeId));
      _linecontrollerWriteMonitoredItem.SamplingInterval = 0;
      _linecontrollerWriteMonitoredItem.DiscardOldest = true;
      _linecontrollerWriteMonitoredItem.QueueSize = 10;
      _linecontrollerWriteMonitoredItem.MonitoringMode = MonitoringMode.Reporting;
      monitoredItems.Add(LinecontrollerWriteMonitoredItem);
      _linecontrollerValidateMonitoredItem = new DataMonitoredItem(NodeId.Parse(Identifier.LcValidateNodeId));
      _linecontrollerValidateMonitoredItem.SamplingInterval = 0;
      _linecontrollerValidateMonitoredItem.DiscardOldest = true;
      _linecontrollerValidateMonitoredItem.QueueSize = 10;
      _linecontrollerValidateMonitoredItem.MonitoringMode = MonitoringMode.Reporting;
      monitoredItems.Add(LinecontrollerValidateMonitoredItem);
In the server the items are registered with MinimumSamplingInterval = 1
The servers minimumPublishingInterval is default = 100.

Any idea what could cause the client/server subscription to stop working?
How can I change the minimumPublishingInterval without using app.config?

Thanks for your help,
Matthias Sandmann

User avatar
Support Team
Hero Member
Hero Member
Posts: 3070
Joined: 18 Mar 2011, 15:09

Re:SDK Client-Server scenario: Either Subscription is not updated or subscriber misses the update

Post by Support Team »

Hi,

Do you use the .NET SDK on the server side as well?

If yes, how did you create the variables there?
Do you have some code snippets for the server side?

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

Sandmann
Jr. Member
Jr. Member
Posts: 2
Joined: 07 Dec 2012, 17:02

Re:SDK Client-Server scenario: Either Subscription is not updated or subscriber misses the update

Post by Sandmann »

Hi,

on server side we also use the SDK.
Basically we took the ServerManager from the example and only "customized" the Startup() routine of NodeManager.

The linecontrollinginterface.xml file was generated using UaModeler.
The object instances created and passed in into 'LinkModelToNode' routine are auto-generated by UaModeler

My collegue just created a VisualBasic.Net project on top of the generated C# code.

Code: Select all

Public Overrides Sub Startup()
    AddNamespaceUri("http://Kostal.com/LineControllingClient/" + Dns.GetHostName())
    Dim TypeNamespaceIndex = AddNamespaceUri(Kostal.com.Kostal_LineControlling_Opc.Namespaces.Kostal_LineControlling_Opc)

    'Step 1: Import type file generated with UaModeler
    ImportUaNodeset(System.Reflection.Assembly.GetExecutingAssembly(), "linecontrollinginterface.xml")

    'create a folder
    Dim myFolderId = New NodeId(Dns.GetHostName(), DefaultNamespaceIndex)

    Dim settings As New CreateObjectSettings() With { _
                    .ParentNodeId = UnifiedAutomation.UaBase.ObjectIds.ObjectsFolder, _
                    .ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes, _
                    .RequestedNodeId = myFolderId, _
                    .BrowseName = New QualifiedName(Dns.GetHostName(), DefaultNamespaceIndex), _
                    .TypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.FolderType _
                }

    CreateObject(Server.DefaultRequestContext, settings)

    'create the transaction object
    Dim lcWriterId = New NodeId("LineControllingWrite", DefaultNamespaceIndex)
    settings = New CreateObjectSettings() With { _
                    .ParentNodeId = myFolderId, _
                    .ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes, _
                    .RequestedNodeId = lcWriterId, _
                    .BrowseName = New QualifiedName("LineControllingWrite", DefaultNamespaceIndex), _
                    .TypeDefinitionId = New NodeId(Kostal.com.Kostal_LineControlling_Opc.ObjectTypes.LineControllingWrite, TypeNamespaceIndex) _
                }
    CreateObject(Server.DefaultRequestContext, settings)

    _lineControllingWriter = New LineControllingWrite()
    LinkModelToNode(lcWriterId, _lineControllingWriter, Nothing, Nothing, 1)



    'create the transaction object
    Dim lcValidatorId = New NodeId("LineControllingValidation", DefaultNamespaceIndex)
    settings = New CreateObjectSettings() With { _
                    .ParentNodeId = myFolderId, _
                    .ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes, _
                    .RequestedNodeId = lcValidatorId, _
                    .BrowseName = New QualifiedName("LineControllingValidation", DefaultNamespaceIndex), _
                    .TypeDefinitionId = New NodeId(Kostal.com.Kostal_LineControlling_Opc.ObjectTypes.LineControllingValidation, TypeNamespaceIndex) _
                }
    CreateObject(Server.DefaultRequestContext, settings)

    _lineControllingValidator = New LineControllingValidation()
    LinkModelToNode(lcValidatorId, _lineControllingValidator, Nothing, Nothing, 1)



    'create the transaction object
    Dim lcAssembleId = New NodeId("LineControllingAssemble", DefaultNamespaceIndex)
    settings = New CreateObjectSettings() With { _
                    .ParentNodeId = myFolderId, _
                    .ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes, _
                    .RequestedNodeId = lcAssembleId, _
                    .BrowseName = New QualifiedName("LineControllingAssemble", DefaultNamespaceIndex), _
                    .TypeDefinitionId = New NodeId(Kostal.com.Kostal_LineControlling_Opc.ObjectTypes.LineControllingAssemble, TypeNamespaceIndex) _
                }
    CreateObject(Server.DefaultRequestContext, settings)

    _lineControllingAssembler = New LineControllingAssemble()
    LinkModelToNode(lcAssembleId, _lineControllingAssembler, Nothing, Nothing, 1)

End Sub
Thanks,
Matthias Sandmann

Post Reply