A new batch of OPCPublisher direct methods

Recently, Microsoft put some real effort into updating the OPCPublisher project. This application/IoT Edge Module ingests telemetry from an OPC-UA Server.

I already wrote two blogs about it: Getting started with OPC-UA on Azure IoT Edge and Managing nodes from the cloud in the OPC-UA Publisher Edge. The seconds one showed how to connect to the OPCPublisher as an IoT Edge module using DirectMethods.

New methods have arrived, this time we get information about the module itself.

Let’s check them out.

GetInfo

This method returns information about the operating system and module.

If we fire this method, we need to pas an empty body, that means:

{
}

The answer is:

{
  "status":200,
  "payload":{
    "VersionMajor":2,
    "VersionMinor":3,
    "VersionPatch":0,
    "SemanticVersion":"2.3.0+Branch.master.Sha.78b97c79ee15aa818c69e07537e98dbbe79deabb",
    "InformationalVersion":"2.3.0+Branch.master.Sha.78b97c79ee15aa818c69e07537e98dbbe79deabb",
    "OS":"Microsoft Windows 10.0.17763 ",
    "OSArchitecture":1,
    "FrameworkDescription":".NET Core 4.6.27129.04"
  }
}

GetDiagnosticInfo

This method returns information about the number of messages received and sent.

If we fire this method, we need to pas an empty body, that means:

{
}

The answer is:

{
  "status":200,
    "payload":{
    "PublisherStartTime":"2019-02-07T16:58:10.9672307Z",
    "NumberOfOpcSessionsConfigured":1,
    "NumberOfOpcSessionsConnected":1,
    "NumberOfOpcSubscriptionsConfigured":1,
    "NumberOfOpcSubscriptionsConnected":1,
    "NumberOfOpcMonitoredItemsConfigured":2,
    "NumberOfOpcMonitoredItemsMonitored":2,
    "NumberOfOpcMonitoredItemsToRemove":0,
    "MonitoredItemsQueueCapacity":8192,
    "MonitoredItemsQueueCount":0,
    "EnqueueCount":23026,
    "EnqueueFailureCount":0,
    "NumberOfEvents":23026,
    "SentMessages":1153,
    "SentLastTime":"2019-02-08T18:14:28.6837746Z",
    "SentBytes":4449931,
    "FailedMessages":0,
    "TooLargeCount":0,
    "MissedSendIntervalCount":7930,
    "WorkingSetMB":62,
    "DefaultSendIntervalSeconds":10,
    "HubMessageSize":262144,
    "HubProtocol":6
  }
}

GetDiagnosticLog

This method returns diagnostic logging information about the number of messages received and sent.

This is just a JSON version of the normal output.

If we fire this method, we need to pas an empty body, that means:

{
}

The answer is:

{
  "status":200,
  "payload":{
    "MissedMessageCount":5175,
    "LogMessageCount":100,
    "Log":[
      "[7:18:22 PM INF] OPC sessions (configured/connected): 1/1",
      "[7:18:22 PM INF] OPC subscriptions (configured/connected): 1/1",
      "[7:18:22 PM INF] OPC monitored items (configured/monitored/to remove): 2/2/0",
      "[7:18:22 PM INF] ---------------------------------",
      "[7:18:22 PM INF] monitored items queue bounded capacity: 8192",
      "[7:18:22 PM INF] monitored items queue current items: 0",
      "[7:18:22 PM INF] monitored item notifications enqueued: 23474",
      "[7:18:22 PM INF] monitored item notifications enqueue failure: 0",
      "[7:18:22 PM INF] ---------------------------------",
      "[7:18:22 PM INF] messages sent to IoTHub: 1176",
      "[7:18:22 PM INF] last successful msg sent @: 2/8/2019 6:18:18 PM",
      "[7:18:22 PM INF] bytes sent to IoTHub: 4538895",
      "[7:18:22 PM INF] avg msg size: 3859",
      "[7:18:22 PM INF] msg send failures: 0",
      "[7:18:22 PM INF] messages too large to sent to IoTHub: 0",
      "[7:18:22 PM INF] times we missed send interval: 7930",
      "[7:18:22 PM INF] number of events: 23474",
      "[7:18:22 PM INF] ---------------------------------",
      "[7:18:22 PM INF] current working set in MB: 62",
      "[7:18:22 PM INF] --si setting: 10",
      "[7:18:22 PM INF] --ms setting: 262144",
      "[7:18:22 PM INF] --ih setting: Mqtt_Tcp_Only",
      "[7:18:22 PM INF] ==========================================================================",
      "[7:19:22 PM INF] ==========================================================================",
      "[7:19:22 PM INF] OpcPublisher status @ 2/8/2019 6:19:22 PM (started @ 2/7/2019 4:58:10 PM)",
      "[7:19:22 PM INF] ---------------------------------",
      "[7:19:22 PM INF] OPC sessions (configured/connected): 1/1",
      "[7:19:22 PM INF] OPC subscriptions (configured/connected): 1/1",
      "[7:19:22 PM INF] OPC monitored items (configured/monitored/to remove): 2/2/0",
      "[7:19:22 PM INF] ---------------------------------",
      "[7:19:22 PM INF] monitored items queue bounded capacity: 8192",
      "[7:19:22 PM INF] monitored items queue current items: 0",
      "[7:19:22 PM INF] monitored item notifications enqueued: 23594",
      "[7:19:22 PM INF] monitored item notifications enqueue failure: 0",
      "[7:19:22 PM INF] ---------------------------------",
      "[7:19:22 PM INF] messages sent to IoTHub: 1182",
      "[7:19:22 PM INF] last successful msg sent @: 2/8/2019 6:19:18 PM",
      "[7:19:22 PM INF] bytes sent to IoTHub: 4562121",
      "[7:19:22 PM INF] avg msg size: 3859",
      "[7:19:22 PM INF] msg send failures: 0",
      "[7:19:22 PM INF] messages too large to sent to IoTHub: 0",
      "[7:19:22 PM INF] times we missed send interval: 7930",
      "[7:19:22 PM INF] number of events: 23594",
      "[7:19:22 PM INF] ---------------------------------",
      "[7:19:22 PM INF] current working set in MB: 62",
      "[7:19:22 PM INF] --si setting: 10",
      "[7:19:22 PM INF] --ms setting: 262144",
      "[7:19:22 PM INF] --ih setting: Mqtt_Tcp_Only",
      "[7:19:22 PM INF] ==========================================================================",
      "[7:20:22 PM INF] ==========================================================================",
      "[7:20:22 PM INF] OpcPublisher status @ 2/8/2019 6:20:22 PM (started @ 2/7/2019 4:58:10 PM)",
      "[7:20:22 PM INF] ---------------------------------",
      "[7:20:22 PM INF] OPC sessions (configured/connected): 1/1",
      "[7:20:22 PM INF] OPC subscriptions (configured/connected): 1/1",
      "[7:20:22 PM INF] OPC monitored items (configured/monitored/to remove): 2/2/0",
      "[7:20:22 PM INF] ---------------------------------",
      "[7:20:22 PM INF] monitored items queue bounded capacity: 8192",
      "[7:20:22 PM INF] monitored items queue current items: 0",
      "[7:20:22 PM INF] monitored item notifications enqueued: 23714",
      "[7:20:22 PM INF] monitored item notifications enqueue failure: 0",
      "[7:20:22 PM INF] ---------------------------------",
      "[7:20:22 PM INF] messages sent to IoTHub: 1188",
      "[7:20:22 PM INF] last successful msg sent @: 2/8/2019 6:20:18 PM",
      "[7:20:22 PM INF] bytes sent to IoTHub: 4585324",
      "[7:20:22 PM INF] avg msg size: 3859",
      "[7:20:22 PM INF] msg send failures: 0",
      "[7:20:22 PM INF] messages too large to sent to IoTHub: 0",
      "[7:20:22 PM INF] times we missed send interval: 7930",
      "[7:20:22 PM INF] number of events: 23714",
      "[7:20:22 PM INF] ---------------------------------",
      "[7:20:22 PM INF] current working set in MB: 62",
      "[7:20:22 PM INF] --si setting: 10",
      "[7:20:22 PM INF] --ms setting: 262144",
      "[7:20:22 PM INF] --ih setting: Mqtt_Tcp_Only",
      "[7:20:22 PM INF] ==========================================================================",
      "[7:21:22 PM INF] ==========================================================================",
      "[7:21:22 PM INF] OpcPublisher status @ 2/8/2019 6:21:22 PM (started @ 2/7/2019 4:58:10 PM)",
      "[7:21:22 PM INF] ---------------------------------",
      "[7:21:22 PM INF] OPC sessions (configured/connected): 1/1",
      "[7:21:22 PM INF] OPC subscriptions (configured/connected): 1/1",
      "[7:21:22 PM INF] OPC monitored items (configured/monitored/to remove): 2/2/0",
      "[7:21:22 PM INF] ---------------------------------",
      "[7:21:22 PM INF] monitored items queue bounded capacity: 8192",
      "[7:21:22 PM INF] monitored items queue current items: 0",
      "[7:21:22 PM INF] monitored item notifications enqueued: 23834",
      "[7:21:22 PM INF] monitored item notifications enqueue failure: 0",
      "[7:21:22 PM INF] ---------------------------------",
      "[7:21:22 PM INF] messages sent to IoTHub: 1194",
      "[7:21:22 PM INF] last successful msg sent @: 2/8/2019 6:21:18 PM",
      "[7:21:22 PM INF] bytes sent to IoTHub: 4608533",
      "[7:21:22 PM INF] avg msg size: 3859",
      "[7:21:22 PM INF] msg send failures: 0",
      "[7:21:22 PM INF] messages too large to sent to IoTHub: 0",
      "[7:21:22 PM INF] times we missed send interval: 7930",
      "[7:21:22 PM INF] number of events: 23834",
      "[7:21:22 PM INF] ---------------------------------",
      "[7:21:22 PM INF] current working set in MB: 62",
      "[7:21:22 PM INF] --si setting: 10",
      "[7:21:22 PM INF] --ms setting: 262144",
      "[7:21:22 PM INF] --ih setting: Mqtt_Tcp_Only",
      "[7:21:22 PM INF] =========================================================================="
    ]
  }
}

GetDiagnosticStartupLog

This method returns the information shown when the IoT Edge module starts up.

This is just a JSON version of the normal output.

If we fire this method, we need to pas an empty body, that means:

{
}

The answer is:

{
  "status":200,
  "payload":{
    "MissedMessageCount":0,
    "LogMessageCount":46,
    "Log":[
      "[5:58:11 PM INF] Current directory is: C:\\appdata",
      "[5:58:11 PM INF] Log file is: publisher-publisher.log",
      "[5:58:11 PM INF] Log level is: info",
      "[5:58:11 PM INF] OPC Publisher V2.3.0 starting up...",
      "[5:58:11 PM INF] opcstacktracemask set to: 0x0",
      "[5:58:11 PM INF] OperationTimeout set to 120000",
      "[5:58:11 PM INF] OPC UA server base address: opc.tcp://publisher:62222/UA/Publisher",
      "[5:58:11 PM INF] Security policy http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 with mode SignAndEncrypt added",
      "[5:58:11 PM INF] Trusted Issuer store type is: Directory",
      "[5:58:11 PM INF] Trusted Issuer Certificate store path is: pki/issuer",
      "[5:58:11 PM INF] Trusted Peer Certificate store type is: Directory",
      "[5:58:11 PM INF] Trusted Peer Certificate store path is: pki/trusted",
      "[5:58:11 PM INF] Rejected certificate store type is: Directory",
      "[5:58:11 PM INF] Rejected Certificate store path is: pki/rejected",
      "[5:58:11 PM INF] Rejection of SHA1 signed certificates is disabled",
      "[5:58:11 PM INF] Minimum certificate key size set to 1024",
      "[5:58:11 PM INF] Application Certificate store type is: Directory",
      "[5:58:11 PM INF] Application Certificate store path is: pki/own",
      "[5:58:11 PM INF] Application Certificate subject name is: publisher",
      "[5:58:11 PM WAR] WARNING: Automatically accepting certificates. This is a security risk.",
      "[5:58:11 PM INF] Application certificate with thumbprint 'B656ECEAF94D53B6931B191CDE6E414D0B4DD6B0' found in the application certificate store.",
      "[5:58:11 PM INF] Application certificate is for ApplicationUri 'urn:publisher:publisher:microsoft:', ApplicationName 'publisher' and Subject is 'publisher'",
      "[5:58:11 PM INF] Adding server certificate to trusted peer store. StorePath=pki/trusted",
      "[5:58:11 PM WAR] Can not add server certificate to trusted peer store. Maybe it is already there.", "A certificate with the same thumbprint is already in the store."," at Opc.Ua.DirectoryCertificateStore.Add(X509Certificate2 certificate, String password)\r\n at OpcPublisher.OpcApplicationConfiguration.InitApplicationSecurityAsync() in C:\\app\\opcpublisher\\OpcApplicationConfigurationSecurity.cs:line 241",
      "[5:58:11 PM INF] LDS(-ME) registration intervall set to 0 ms (0 means no registration)",
      "[5:58:11 PM INF] Trusted issuer store contains 0 certs",
      "[5:58:11 PM INF] Trusted issuer store has 0 CRLs.",
      "[5:58:11 PM INF] Trusted peer store contains 1 certs",
      "[5:58:11 PM INF] 01: Subject 'CN=publisher' (thumbprint: B656ECEAF94D53B6931B191CDE6E414D0B4DD6B0)",
      "[5:58:11 PM INF] Trusted peer store has 0 CRLs.",
      "[5:58:11 PM INF] Rejected certificate store contains 0 certs",
      "[5:58:11 PM INF] There is no site configured.",
      "[5:58:12 PM INF] Starting server on endpoint opc.tcp://publisher:62222/UA/Publisher ...",
      "[5:58:15 PM INF] Server started.",
      "[5:58:15 PM INF] Using default telemetry configuration.",
      "[5:58:15 PM INF] The name of the configuration file for published nodes is: ./pn.json",
      "[5:58:15 PM INF] Attemtping to load node configuration from: ./pn.json",
      "[5:58:16 PM INF] Loaded 1 config file entry/entries.",
      "[5:58:16 PM INF] There are 2 nodes to publish.",
      "[5:58:16 PM INF] Create IoTEdgeHub module client using 'Mqtt_Tcp_Only' for communication.",
      "[5:58:16 PM INF] IoTCentral mode: False",
      "[5:58:18 PM INF] Connection status changed to 'Connected', reason 'Connection_Ok'",
      "[5:58:18 PM INF] Message processing and hub communication configured with a send interval of 10 sec and a message buffer size of 262144 bytes.",
      "[5:58:18 PM INF] Creating task process and batch monitored item data updates..."
    ]
  }
}

ExitApplication

At first, I was thinking ‘this will not work’ for an IoT Edge module. But it works! The module is reset!

This method stops the IoT Edge module gracefully and the module is started up again.

If we fire this method, we need to pas an empty body, that means:

{
}

The answer is:

{
  "status":200,
  "payload":[
    "Module will exit in 0 seconds"
  ]
}

I did not need this DirectMethod yet but maybe there is some need for it in the future 🙂

Conclusion

With these new DirectMethods we have an easy solution to see what’s happening inside the OPCPublisher IoT module.

Especially the log regarding how the module starts up is most interesting, it gives excellent feedback regarding the Module Container Create options.

 

 

 

 

 

 

 

Advertenties