Skip to main content
Version: 1.8.5

CREATING AN OPC-UA CONNECTION

Available since ThingPark X IoT Flow 1.6.1.

Note

The OPC-UA connector is available only on ThingPark Enterprise OCP.

The OPC-UA connection sends the data of your devices and gateways to an OPC-UA server embedded in the connection. The link is unidirectional.

Uplinks from devices are decoded and mapped automatically to node values of the OPC-UA namespace. Gateway statistics are exposed on the same server. Your OPC-UA clients connect to this server and read the node values. Aliases let you publish values on existing node IDs.

The embedded OPC-UA server has a discovery mechanism. A discovery endpoint without security is good practice. It is required when all the regular endpoints have security configured. OPC UA Part 6 defines the use of the /discovery suffix:

Each OPC UA Server Application implements the Discovery Service Set. If the OPC UA Server requires a different address for this Endpoint it shall create the address by appending the path "/discovery" to its base address.

Overview​

Overview of the OPC-UA connection

By default, each message is transformed by the "Message Simplifier" processor, which keeps only the important data: a set of LoRaWAN fields such as RSSI and SNR, and the decoded payload. All the fields of the transformed message are exposed on the OPC-UA server. The root path of each device is set by deviceNodeIdPattern.

You can scope each transformation to a device model, to get the structure and naming convention you expect.

Tree of the OPC-UA namespace

Collecting Expected Information​

Basic Settings​

Basic settings of an OPC-UA connection
UI FieldDescription
Bind AddressIP address on which the embedded OPC-UA server listens, when the server has several network interfaces.
TCP Bind PortPort on which the embedded OPC-UA server listens for the TCP transport profile, from 4840 to 4845.
PathBase path of the embedded OPC-UA server.
UsernameUser name for basic authentication on the OPC-UA server.
PasswordPassword for basic authentication on the OPC-UA server.
Base Station Node ID PatternPattern of the node IDs where the gateway information is published.
Device Node ID PatternPattern of the node IDs where the device information is published.
Server CertificateCertificate that secures the TCP communication. See Server Certificate.
Server Private KeyPrivate key of the server certificate.

Advanced Settings​

The following settings are in the Advanced Settings section of the connection details, once the connection is created:

Advanced settings of an OPC-UA connection
UI FieldDescription
Domain NameDomain name of the OPC-UA server. If you are not sure, use the same IP address as Bind Address.
Discovery PathPath of the discovery endpoint of the OPC-UA server. /discovery is recommended.
Client CertificateCertificate of the only client allowed to connect. See Client Certificate.
Purge All DataRemoves all the values kept by the connection. See Persistence and Purge.
Allow insecure endpointOpens an insecure endpoint next to the secure endpoint.
Uplink ValidityMaximum age of an uplink, for example 1m. An older uplink is not sent, and an alarm event is saved in the events log. While a connection is not started or is down, uplinks pile up, and most of them expire before the connection is up again. Examples: 60m, 12h, 3d12h60m.
DebugLogs more details about the connection, for troubleshooting. It turns itself off after two days.

Client Certificate​

When you set a client certificate on the connection, only the client with this certificate can connect. The certificate comes from the client, in PEM format.

Example with UAExpert:

Client certificate in UAExpert

You can export this certificate and convert it from DER to PEM format with OpenSSL:

openssl x509 -inform der -in uaexpert.der -out uaexpert.pem

Server Certificate​

When you set a server certificate on the connection, the TCP communication is secured. You can generate a server certificate in PEM format with OpenSSL:

openssl req -x509 -newkey rsa:4096 -keyout opcua_server_pk.pem -out opcua_server_cert.pem -sha256 -days 36500 -nodes -subj "/C=FR/ST=IleDeFrance/L=Paris/O=Actility/OU=R&D/CN=Localhost" -extensions san -config <(echo '[req]'; echo 'distinguished_name=req'; echo '[san]'; echo 'subjectAltName=URI:urn:actility:tpx:iot-flow:opcua-server,DNS:localhost')
Note

The certificate must contain a subjectAltName with the application URI and the DNS name, for example URI:urn:actility:tpx:iot-flow:opcua-server,DNS:localhost.

Aliases​

The OPC-UA connection supports aliases of node IDs. In the Alias rules panel, enter the original path and the expected path.

Alias rules of an OPC-UA connection

Discovery Feature​

The OPC-UA connector supports the discovery feature. Make sure that Domain Name is set.

Discovery settings of an OPC-UA connection

Creating a Connection With UI​

  1. In ThingPark Enterprise, click Connections -> + Add Connection -> ThingPark X IoT Flow.
Add a ThingPark X IoT Flow connection in ThingPark Enterprise
  1. In ThingPark X IoT Flow, click OPC UA in the list of connectors.
Select the OPC-UA connector
  1. Fill in the form as in the example below. See Collecting Expected Information.
Set your OPC-UA connection
  1. Click Create. A notification confirms that the connection has been created.
Notification of the connection creation
  1. The connection details open.
OPC-UA connection details
Note

Parameters marked with * are mandatory.

Changing the Settings After Creation​

In the connection details, the Basic Settings and Advanced Settings sections show the settings of the connection.

  1. Click the Edit button next to the setting to change.
Edit a setting of the OPC-UA connection
  1. Enter the new value and click the Confirm button.
Confirm the new value
  1. Confirm the update.
Confirm the update

A notification confirms that the setting is updated.

Notification of the update

Creating a Connection With API​

To do this, you need to use the Connections group resource:

  • POST /connections to create a new Connection instance
  • PUT /connections to update a Connection instance
  • DELETE /connections to delete a Connection instance
Note

We follow the REST-full API pattern, when updating configuration properties for a connection resource. Thus, you must also provide the whole configuration again.

Example for creation of a new connection instance:

POST /connections
{
"connectorId": "actility-opcua-iot",
"name": "Actility OPC-UA Connection",
"configuration": {
"bindAddress": "0.0.0.0",
"domainName": "opcua.company.com",
"discoveryPath": "/discovery",
"tcpBindPort": 4840,
"path": "/tpx",
"username": "my-opcua-user",
"password": "{YOUR-OPCUA-PASSWORD}",
"purgeNamespace": false,
"openBothSecureAndInsecureEndpoints": false,
"deviceNodeIdPattern": "IoTHub/Devices/{DevEUI}",
"baseStationNodeIdPattern": "IoTHub/Gateways/{Id}",
"aliases": [
{
"path": "IoTHub/Devices/A81758FFFE04F27E/temperature",
"mappedPath": "AliasTemperature/Alias/Tag0001"
},
{
"path": "IoTHub/Devices/A81758FFFE04F27E/humidity",
"mappedPath": "AliasHumidity/Tag0002"
},
{
"path": "IoTHub/Devices/A81758FFFE04F27E/light",
"mappedPath": "Light/Alias/Tag0003"
}
],
"clientCertificate": "-----BEGIN CERTIFICATE-----MIIEyzCCA7O ... 5z0SXZIjpQ==-----END CERTIFICATE-----",
"serverCertificate": "-----BEGIN CERTIFICATE-----MIIEnTCCA ... DLnhn-----END CERTIFICATE-----",
"serverPrivateKey": "-----BEGIN PRIVATE KEY-----MIIEvQIB ... 1ROtDV8=-----END PRIVATE KEY-----"
}
}

The following table lists the properties applicable to a connection instance.

FieldDescription
connectorIdMust be set to actility-opcua-iot.
configuration/bindAddressBind Address.
configuration/tcpBindPortTCP Bind Port, from 4840 to 4845.
configuration/pathPath.
configuration/username and configuration/passwordUsername and Password. The password is masked when the connection is read.
configuration/deviceNodeIdPatternDevice Node ID Pattern, for example IoTHub/Devices/{DevEUI}.
configuration/baseStationNodeIdPatternBase Station Node ID Pattern, for example IoTHub/Gateways/{Id}.
configuration/serverCertificate and configuration/serverPrivateKeyServer Certificate and Server Private Key, in PEM format. Masked when the connection is read.
configuration/domainNameDomain Name.
configuration/discoveryPathDiscovery Path.
configuration/clientCertificateClient Certificate, in PEM format. Masked when the connection is read.
configuration/openBothSecureAndInsecureEndpointstrue for Allow insecure endpoint. Default false.
configuration/purgeNamespacetrue to remove all the values kept by the connection (Purge All Data). Default false.
configuration/aliasesAlias rules: a list of path (original path) and mappedPath (expected path).
Important note

All properties are not present in this example. You can check the rest of these properties in the common parameters section.

Structure of the OPC-UA Namespace​

The OPC-UA namespace is organized as a folder hierarchy. The top (root) folder of the namespace is named IoTHub.

Root folder of the OPC-UA namespace

The IoTHub folder holds two folders, Devices and Gateways:

  • The Devices folder holds the devices that have sent uplinks.
  • The Gateways folder holds the base stations.

Devices Folder​

When a device sends its first uplink, a folder named after its DevEUI is created under Devices.

Devices folder

When you expand a device folder, you can see the attributes of the device.

Attributes of a device

When you click an attribute, the Attributes tab on the right panel of your OPC-UA client shows its type, its value and other information.

Details of a device attribute

Gateways Folder​

A scheduled job collects the base stations periodically, and creates a folder for the ID of each base station.

Gateways folder

When you expand a gateway folder, you can see the attributes of the base station.

Attributes of a gateway

When you click an attribute, the Attributes tab on the right panel of your OPC-UA client shows its type, its value and other information.

Details of a gateway attribute

Device Alarms​

Devices can send alarm messages to the OPC-UA connection, for example when no data has been received for a while. These alarms set the data quality of the related OPC-UA nodes to "Uncertain". The quality goes back to "Good" when a fresh value is received.

Persistence and Purge​

Every minute, the OPC-UA connection stores the values of all its node IDs locally. When the connection restarts, all the values are restored with the data quality "Uncertain". The quality goes back to "Good" when a fresh value is received.

Data quality of restored values

Because of this persistence, an old value is never removed by itself. To remove all the data, use the purge button in the Advanced Settings section.

Purge button in the advanced settings

How To Connect With Kepware​

Kepware
  1. To connect to the OPC-UA server with Kepware, create a new channel in the KEPServerEX Configuration window: right-click Project -> Connectivity and select New Channel.
New channel in Kepware
  1. Select OPC UA Client as the type of the channel.
Select the OPC UA Client channel type
  1. Enter a name for the new channel.
Name the channel
  1. To let Kepware discover the endpoints of the OPC-UA server, click ... next to the Endpoint URL field.
Endpoint URL field
  1. Enter the discovery URL of the OPC-UA server in the Discovery URL field. Use the domain name, host name or IP address of the OPC-UA server: it must be the same value as Domain Name (domainName) in the connection. If the Discovery URL field is not enabled, check Use Discovery URL. The UA Servers section lists the available endpoints of the connection. Select the endpoint you want to connect to.
Important note

The domain name or IP address in the discovery URL must match the actual domain name or IP address of the OPC-UA server.

Discovery URL in Kepware
  1. Select the security policy supported by the OPC-UA server. If the connection has a server certificate, the security policy must be Basic256Sha256. Otherwise, it must be None. Leave the Message Mode field as None.
Security settings in Kepware
  1. Enter the username and password of the OPC-UA server, if the connection has them. Otherwise, leave both fields empty: authentication is not required. Click Next: the channel is created.
Authentication settings in Kepware
  1. On the new channel in the project tree, click the link to add a new device. The Add Device wizard opens. Enter a device name, such as the DevEUI of the device, and click Next.
Add a device in Kepware
  1. Select the scan mode and the preference for the initial updates.
Scan mode in Kepware
  1. Select Poll as the update mode and select Enable for Registered Read/Write.
Update mode in Kepware
  1. On the next screen, click Select Import Items.
Select import items in Kepware
  1. Browse the namespace tree of the OPC-UA server, select the branches of the devices and properties you want to observe, and click Add Branches. When you are done, click OK.
Select the branches to import in Kepware
Important note

Enable the advanced option Allow insecure endpoint: Kepware needs it. If you use credentials, you need a server certificate.

Allow insecure endpoint option

How To Connect With dataFeed​

dataFeed
  1. To connect to the OPC-UA server with dataFeed, create a new session.
New session in dataFeed
  1. In the Endpoint Url field, enter the URL of the OPC-UA server. Use the domain name, host name or IP address of the OPC-UA server: it must be the same value as Domain Name (domainName) in the connection. Select the security mode and policy supported by the OPC-UA server. If the connection has a server certificate, the security mode must be SignAndEncrypt and the security policy Basic256Sha256. Otherwise, set both to None.

    If the connection has a username and password, set User Identity to UserName and enter them. Otherwise, set User Identity to Anonymous.

Important note

The domain name or IP address in the URL must match the actual domain name or IP address of the OPC-UA server.

Session settings in dataFeed
  1. Click Validate Connection.
Browse the namespace in dataFeed
Important note

Enable the advanced option Allow insecure endpoint: dataFeed needs it. If you use credentials, you need a server certificate.

Allow insecure endpoint option

Associating Devices With the Connection​

In ThingPark Enterprise, open Devices, select a device, and add the connection to the Connections of the device. You can also select the connection when you create a device, or for many devices at once with a CSV file in Devices -> Bulk Operations.

List of devices
Add the connection to a device

A notification confirms that the connection has been added to the device.

Notification of the association

Displaying Information to Know if It Worked​

  1. Download and install an OPC-UA client, for example UaExpert.

  2. Make a device associated with the connection send an uplink.

  3. With the OPC-UA client, connect to the OPC-UA server of the connection, at the address set in the connection.

Connect to the OPC-UA server
  1. Browse the namespace of the OPC-UA server: check that it holds the devices associated with the connection, as set by the node ID patterns and the aliases of the connection. See Structure of the OPC-UA Namespace.
Browse the OPC-UA namespace

Limitations​

  • The TCP port range is limited to 4840 to 4845.
  • The OPC-UA server accepts only one client connection when you use a client certificate.
  • The OPC-UA server does not support authentication based on certificates.
  • The OPC-UA server supports only TCP connections. HTTPS is not supported.
  • The security policy of the OPC-UA server is limited to Basic256Sha256, with the message security mode Sign&Encrypt, when a server certificate is set. Otherwise, no security is required.
  • UaExpert, as an OPC-UA client GUI tool, connects only when the connection has a server private key and a server certificate. Another OPC-UA client GUI tool, FreeOpcUa, does not require a server certificate. However, FreeOpcUa has no username and password authentication, so the username and password of the connection must be empty.
  • The number of items that can be monitored on the server is limited only by CPU and RAM usage. Some clients limit the number of monitored items; in such cases, you can open several sessions in parallel on the same server. For example, the Eclipse Milo OPC UA client is limited to 10K monitored items.
  • On a ThingPark Enterprise OCP Segment XL with ThingPark X IoT Flow 1.8.x, the memory of the OPC-UA connector is limited to 1.3 GB. The maximum number of monitored items is 10K. Up to 500K nodes can be written to the OPC-UA server. To monitor more items, RAM and CPU requirements must be re-evaluated.