CREATING AN OPC-UA CONNECTION
Available since ThingPark X IoT Flow 1.6.1.
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

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.

Collecting Expected Information
Basic Settings

| UI Field | Description |
|---|---|
| Bind Address | IP address on which the embedded OPC-UA server listens, when the server has several network interfaces. |
| TCP Bind Port | Port on which the embedded OPC-UA server listens for the TCP transport profile, from 4840 to 4845. |
| Path | Base path of the embedded OPC-UA server. |
| Username | User name for basic authentication on the OPC-UA server. |
| Password | Password for basic authentication on the OPC-UA server. |
| Base Station Node ID Pattern | Pattern of the node IDs where the gateway information is published. |
| Device Node ID Pattern | Pattern of the node IDs where the device information is published. |
| Server Certificate | Certificate that secures the TCP communication. See Server Certificate. |
| Server Private Key | Private 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:

| UI Field | Description |
|---|---|
| Domain Name | Domain name of the OPC-UA server. If you are not sure, use the same IP address as Bind Address. |
| Discovery Path | Path of the discovery endpoint of the OPC-UA server. /discovery is recommended. |
| Client Certificate | Certificate of the only client allowed to connect. See Client Certificate. |
| Purge All Data | Removes all the values kept by the connection. See Persistence and Purge. |
| Allow insecure endpoint | Opens an insecure endpoint next to the secure endpoint. |
| Uplink Validity | Maximum 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. |
| Debug | Logs 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:

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')
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.

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

Creating a Connection With UI
- In ThingPark Enterprise, click Connections -> + Add Connection -> ThingPark X IoT Flow.

- In ThingPark X IoT Flow, click OPC UA in the list of connectors.
- Fill in the form as in the example below. See Collecting Expected Information.

- Click Create. A notification confirms that the connection has been created.
- The connection details open.

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.
- Click the Edit button next to the setting to change.

- Enter the new value and click the Confirm button.

- Confirm the update.
A notification confirms that the setting is updated.
Creating a Connection With API
To do this, you need to use the Connections group resource:
POST /connectionsto create a new Connection instancePUT /connectionsto update a Connection instanceDELETE /connectionsto delete a Connection instance
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.
| Field | Description |
|---|---|
connectorId | Must be set to actility-opcua-iot. |
configuration/bindAddress | Bind Address. |
configuration/tcpBindPort | TCP Bind Port, from 4840 to 4845. |
configuration/path | Path. |
configuration/username and configuration/password | Username and Password. The password is masked when the connection is read. |
configuration/deviceNodeIdPattern | Device Node ID Pattern, for example IoTHub/Devices/{DevEUI}. |
configuration/baseStationNodeIdPattern | Base Station Node ID Pattern, for example IoTHub/Gateways/{Id}. |
configuration/serverCertificate and configuration/serverPrivateKey | Server Certificate and Server Private Key, in PEM format. Masked when the connection is read. |
configuration/domainName | Domain Name. |
configuration/discoveryPath | Discovery Path. |
configuration/clientCertificate | Client Certificate, in PEM format. Masked when the connection is read. |
configuration/openBothSecureAndInsecureEndpoints | true for Allow insecure endpoint. Default false. |
configuration/purgeNamespace | true to remove all the values kept by the connection (Purge All Data). Default false. |
configuration/aliases | Alias rules: a list of path (original path) and mappedPath (expected path). |
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.

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.

When you expand a device folder, you can see the attributes of the 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.

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

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

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.

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.

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.

How To Connect With Kepware
- 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.

- Select OPC UA Client as the type of the channel.

- Enter a name for the new channel.

- To let Kepware discover the endpoints of the OPC-UA server, click ... next to the Endpoint URL field.

- 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.
The domain name or IP address in the discovery URL must match the actual domain name or IP address of the OPC-UA server.

- 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 beNone. Leave the Message Mode field asNone.

- 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.

- 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.

- Select the scan mode and the preference for the initial updates.

- Select Poll as the update mode and select Enable for Registered Read/Write.

- On the next screen, click Select Import Items.

- 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.

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

How To Connect With dataFeed

- To connect to the OPC-UA server with dataFeed, create a new session.

-
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 beSignAndEncryptand the security policyBasic256Sha256. Otherwise, set both toNone.If the connection has a username and password, set User Identity to
UserNameand enter them. Otherwise, set User Identity toAnonymous.
The domain name or IP address in the URL must match the actual domain name or IP address of the OPC-UA server.

- Click Validate Connection.

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

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.


A notification confirms that the connection has been added to the device.
Displaying Information to Know if It Worked
-
Download and install an OPC-UA client, for example UaExpert.
-
Make a device associated with the connection send an uplink.
-
With the OPC-UA client, connect to the OPC-UA server of the connection, at the address set in the connection.

- 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.

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 modeSign&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.