Skip to main content

OPC UA Client

This page documents the client connector (OPCUA)—the broker connects to a remote OPC UA server and reads or writes device data over MQTT. To expose MQTT topics to OPC UA clients instead (SCADA, UaExpert, PLCs connect to the broker), see OPC UA Server.
The OPCUA connector enables communication with OPC UA servers, providing a standardized, cross-platform protocol for industrial automation. It supports multiple authentication modes, security policies, and both NodeId and BrowsePath addressing.
OPC UA is vendor-neutral and widely supported by modern industrial equipment. Use it when you need secure, standardized communication across different manufacturer’s devices.

Basic Syntax


Connection Configuration

OPCUA_CONFIG Parameters

string
required
OPC UA server endpoint URL (e.g., opc.tcp://localhost:4840).
integer
Authentication mode:
  • 0 - Anonymous (no authentication)
  • 1 - Username/Password
  • 2 - Certificate
Default: 0.
string
Username for authentication (required if AUTH_MODE is 1).
string
Password for authentication (required if AUTH_MODE is 1).
boolean
Enable security mode. Default: false.
integer or string
Security policy, as a number or its name (WITH SECURITY_POLICY "Basic256Sha256"):
  • 0 - None
  • 1 - Basic128Rsa15
  • 2 - Basic256
  • 3 - Basic256Sha256
  • 4 - Aes128_Sha256_RsaOaep
  • 5 - Aes256_Sha256_RsaPss
Default: 0.
integer or string
Message security mode, as a number or its name (WITH MESSAGE_SECURITY "SignAndEncrypt"):
  • 0 - None
  • 1 - Sign
  • 2 - SignAndEncrypt
Default: 0.
string
Root directory for the four-folder PKI store (own, issuer, trusted, rejected). When omitted, the broker uses the operating-system default only if that folder is writable. Otherwise it uses <dataDir>/pki/opcua. An explicit path that is not writable fails. See Where certificates live.
string
Path to a PKCS#12 (.pfx) or PEM client certificate used when AUTH_MODE is 2. The broker loads it, adopts its application URI, and stores it under PKI_DIR/own. When omitted, a self-signed certificate is auto-generated on first connect.
string
Path to the private key PEM file when CLIENT_CERT_PATH points to a certificate-only PEM. Not needed for PKCS#12 bundles.
string
Password for the PKCS#12 bundle or encrypted private key. Use GET SECRET—never hard-code passwords in connector definitions.
boolean
Automatically accept untrusted server certificates. Default: false. For production, leave false and trust the server certificate explicitly—see Certificate Management.
boolean
Suppress nonce validation errors. Default: false.
integer
Connection timeout in milliseconds. Default: 90000.

Security Configuration

For development or trusted networks:

Certificate Management

A secured OPC UA client connection requires two certificates that trust each other: the broker’s application instance certificate (channel security and, with AUTH_MODE 2, user identity) and the server’s certificate (must be in your trusted store). For server-side trust workflows, see OPC UA Server.
Like exchanging ID badges at a secure facility. Both sides must recognize each other’s badge before the door opens—moving a certificate from rejected to trusted is how you approve a new badge.

PKI directory layout

Both client and server connectors store certificates in four folders under PKI_DIR:

Where certificates live

When PKI_DIR is not set, the broker uses the operating-system default only if that folder is writable: If that folder is not writable, the broker uses <dataDir>/pki/opcua. <dataDir> is COREFLUX_DATA_PATH, or CONFIG_PATH when that variable is unset. In the container image the operating-system default resolves to /OPC Foundation/pki, which the container user cannot write, so the connector uses the data-directory path. Compose and cluster setups already mount that directory. The start log names the path it chose and says that PKI_DIR overrides it. In a cluster, that fallback gives each node its own self-generated certificate. Set PKI_DIR to shared storage when every node should present one identity. An explicit PKI_DIR that the broker cannot write still fails. The broker does not substitute another folder. If the fallback is used and <dataDir>/pki/own exists without <dataDir>/pki/opcua, the start log warns once. Point the store at a path you control:
Keep the chosen folder on storage that survives a restart. A certificate that is recreated on every start is rejected by any server that trusted the previous one.

Inspecting and exporting certificates

Certificates are plain files you can inspect with openssl:
Give peers the public certificate (own/certs/*.der). The private key (own/private/*.pfx) never leaves the broker.

Auto-generated client certificate

With AUTH_MODE 2 and no CLIENT_CERT_PATH, the broker auto-generates a self-signed certificate (CN=CorefluxBroker_OpcUaClient, O=Coreflux) in PKI_DIR/own on first connect:
You still must (1) get this broker certificate trusted by the server and (2) trust the server’s certificate—see the workflows below.
An application instance certificate must carry an application URI in its Subject Alternative Name. The OPC UA stack matches certificates by that URI and rejects certificates without one.

Supply your own client certificate

Use a certificate from your PKI via CLIENT_CERT_PATH. Generate it with a mandatory URI SAN:

Trust the server’s certificate

Required when USE_SECURITY true and AUTO_ACCEPT_UNTRUSTED_CERTIFICATES false:
1

Deploy the connector

The first handshake fails and the server’s certificate is written to PKI_DIR/rejected/certs.
2

Move to trusted

3

Reconnect

The connector reconnects automatically—the handshake now succeeds.
For testing only, skip this with WITH AUTO_ACCEPT_UNTRUSTED_CERTIFICATES true.

Get the broker trusted by the server

For AUTH_MODE 2, the server must trust the broker’s client certificate:
1

Export the broker certificate

2

Add to the server's trust list

Import broker-client.pem (or the .der) into the server’s trusted certificate store—via its PKI trusted folder or vendor certificate manager.
3

Reconnect

The server now accepts the certificate identity.

Rotation and renewal

  • Auto-generated certificates — Delete files in PKI_DIR/own/certs and PKI_DIR/own/private, then reconnect; the broker regenerates a new self-signed certificate.
  • Supplied certificates — Replace the .pfx/PEM file, remove the old copy from PKI_DIR/own, and redeploy. Re-distribute the new public certificate to the server’s trust list before the old one expires.
  • Plan rotation before expiry—an expired application instance certificate fails the handshake.

Verify the connection

After mutual trust is configured, confirm the connector connects:
Publish that command to $SYS/Coreflux/Command. A response with "success": true means the certificate-authenticated session is established.

NodeId Addressing

OPC UA uses NodeIds to identify variables. The format is: ns=<namespace>;s=<identifier> or ns=<namespace>;i=<numeric_id>
An ADDRESS that contains a slash (/) is treated as a browse path, even with USE_BROWSE_PATH off. So a string NodeId with a slash, such as the default ns=2;s=PlantServer/Temperature node of a Coreflux OPC UA server, can’t be read. Give the server tag an explicit ADDRESS without slashes, such as "Line1.Oee", and read ns=2;s=Line1.Oee.

Finding NodeIds

Use an OPC UA browser tool (like UaExpert, Prosys OPC UA Browser, or similar) to explore the server’s address space and find the correct NodeIds.

BrowsePath Mode

For servers that support it, you can use symbolic paths instead of NodeIds:
boolean
Enable BrowsePath mode - treat all TAG addresses as browse paths instead of NodeIds.
string
Root path for browsing when USE_BROWSE_PATH is enabled. Default: Objects.

BrowsePath Example


Data Types

STRING, CHAR, WCHAR, array, and STRUCT tags publish the decoded value on the tag. Two mappings that share a tag name keep their own values. On disconnect, the last real value is published again with quality BAD.
Action: A dashboard that treated a numeric 0 as “no string yet” should use quality BAD, or an empty string.

String sizing

For STRING tags, WITH LENGTH sets the maximum string size in bytes (default 256). STRING_SIZE is accepted as an alias for the same field.
For cross-protocol defaults and caps, see String sizing by Connector on the industrial overview.

STRUCT / ExtensionObject payloads

A STRUCT or ExtensionObject value is published as base64 of the body bytes. A consumer needs the node’s DataType definition to decode it. An array of structs (DATA_TYPE "STRUCT" with IS_ARRAY true) publishes a JSON array of base64 strings. A null or unencodable element is "". Read one structure and an array of structures:

Numeric arrays

A numeric tag with IS_ARRAY true (for example FLOAT) publishes a JSON array of numbers. SCALING and OFFSET are not applied, so an array that has scaling configured publishes the unscaled values.

TAG Configuration

Complete TAG Example

TAG Parameters

string
required
OPC UA NodeId (e.g., ns=2;s=MyVariable or ns=2;i=1234) or BrowsePath if USE_BROWSE_PATH is enabled.
string
required
OPC UA data type: BOOLEAN, BYTE, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, STRING, STRUCT. A STRUCT value is base64 of the ExtensionObject body. See STRUCT / ExtensionObject payloads.
boolean
Indicates if the value is an array. Default: false. A numeric array publishes a JSON array of numbers and skips SCALING and OFFSET. A STRUCT array publishes a JSON array of base64 strings. See Numeric arrays.
integer
default:"256"
STRING only. Maximum string size in bytes. Alias: STRING_SIZE.
double
Multiplier for value transformation. Default: 1.0. Not applied to numeric IS_ARRAY tags. Those tags publish the unscaled numbers.
double
Offset added after scaling. Default: 0.0.
integer
Decimal places in output. Default: 2.
double
Lowest value, in engineering units. Reads are clamped to it. A write below it follows WRITE_LIMIT. See Write results.
double
Highest value, in engineering units. Reads are clamped to it. A write above it follows WRITE_LIMIT. Must not be below MIN_VALUE.
string
What a write outside MIN_VALUE / MAX_VALUE does. "REJECT" (default) sends nothing and reports "success": false. "CLAMP" sends the nearest limit and reports "clamped": true. Any other value is a LoT error. See Write results.
double
Minimum change to trigger publish. Default: 0.0.
string
Topic where PLC values are published. Subscribe here to receive sensor data.
string
Output format: VALUE_ONLY or JSON. Default: VALUE_ONLY.
string
Engineering unit for documentation.
string
Human-readable description.
boolean
Allow writing to this node. Default: false.
string
Topic to send write commands. Publish a value here to write it to the PLC.

Event-Based Operations

For on-demand OPC UA operations (not polling), use the EVENT syntax. Publish a message to SOURCE_TOPIC to trigger the operation; the connector executes it and publishes the result to DESTINATION_TOPIC.

Supported Operations

Query Parameters

Read Example

Read a node value on demand:

Write Example

Write a FLOAT value to a node on demand:

Complete Examples

Simple OPC UA connection with anonymous access:

Security Best Practices

Always enable security for production deployments:
In production, properly configure certificate trust:
Move server certificates from PKI_DIR/rejected/certs to PKI_DIR/trusted/certs during commissioning. See Certificate Management.
Prefer username/password or certificate authentication over anonymous:

Troubleshooting

  • Verify endpoint URL is correct
  • Check firewall allows TCP port (usually 4840)
  • Ensure server is running and accessible
  • Try increasing TIMEOUT value
  • Verify security policy matches server configuration
  • Server certificate not trusted — Move it from PKI_DIR/rejected/certs to PKI_DIR/trusted/certs, or set AUTO_ACCEPT_UNTRUSTED_CERTIFICATES true for testing only
  • Supplied certificate ignored — Reissue with a subjectAltName=URI:... SAN; certificates without an application URI are rejected
  • Server rejects client certificate — Export the broker’s public cert from PKI_DIR/own/certs and add it to the server’s trust list
  • Certificate regenerates every restart — The store is on storage that does not survive a restart. Set PKI_DIR to a persistent path, or leave it unset so the broker can use <dataDir>/pki/opcua on the mounted data directory. See Where certificates live
  • BadCertificateUriInvalid — Regenerate the certificate or set a stable application URI in the SAN
  • Verify the file path is correct and readable by the broker
  • Check CLIENT_CERT_PASSWORD matches the PKCS#12 bundle or encrypted key
  • For a split PEM (certificate and key in separate files), set CLIENT_KEY_PATH
  • The broker log names the failing file—check it for the exact cause
  • Use OPC UA browser to verify correct NodeId
  • Check namespace index (ns=) is correct
  • Verify node exists in server’s address space
  • Try BrowsePath mode if NodeId is unclear
  • Verify username and password
  • Check user has appropriate permissions
  • Ensure AUTH_MODE matches server requirements
  • Verify DATA_TYPE matches server variable type
  • Check IS_ARRAY setting for array values
  • Verify SCALING and OFFSET calculations

Next Steps

OPC UA Server Connector

Expose MQTT topics as OPC UA nodes for SCADA and OT clients.

ADS (Beckhoff)

Connect to TwinCAT systems.
Last modified on December 4, 2026