Skip to content

OPC UA (opcua) ​

Connects to an OPC UA server, reads the state of the server and the value of each node you name, and reports them as channels that can be held to limits. Use it for the controllers, gateways and historians of a plant that publish their readings through OPC UA: a temperature, a counter, a recipe in use, a status you map from text to a number.

What it speaks. Security policy None and an anonymous user. There is no signing, no encryption and no user name login. That is a limit of this sensor, and the page says why and what it means for you below; read it before pointing the sensor at anything but a monitoring network.

What it looks like ​

The page of an opcua sensor in the light theme

The sensor's page after a few polls, reading two nodes. In the dark theme: the sensor's page. The form for adding it, with its parameters filled in: light, dark.

Channels ​

KeyNameUnitDefault limits
connect_msConnect timemswarning above 1000, error above 5000
session_msSession set-up timemswarning above 2000, error above 10000
read_msRead timemswarning above 1000, error above 5000
server_stateServer statenone0 Running is Up; 3 Suspended and 5 Test are Warning; 1 Failed, 2 No configuration, 4 Shutdown and 6 Communication fault are Down
one for each entry of nodesits name, or its keyits unitnone: set them on the sensor

server_state is the server's own ServerStatus.State (node i=2259), read on every poll. A server that says it is not running answers the poll, so this is a successful poll that is Down, with the state named.

Parameters ​

ParameterDefaultMeaning
port4840TCP port of the server (opc.tcp).
server_namethe device's host name, else its addressThe host name to put in the endpoint URL (opc.tcp://<name>:<port>). Servers compare it with their own names, and some refuse an address they do not know.
nodesnoneThe nodes to read, up to 50. Empty is allowed: the sensor then only checks the server and its state.

Each entry of nodes has:

FieldDefaultMeaning
keyrequiredThe channel key: lower case letters, digits and _, up to 40 characters. Not one of the keys in the table above, and not used twice.
node_idrequiredThe node: i=2259 (numeric, namespace 0), ns=2;s=Boiler.Temperature (text), ns=3;i=1001 (numeric in another namespace), ns=2;g=<guid>. Opaque (b=) identifiers are not supported. The namespace index is the server's own; any OPC UA client that browses the server shows it beside each node.
scale, offset1, 0A numeric value is reported times scale plus offset.
value_mapnoneTurns text values into numbers: [{"from": "Idle", "to": 0}, {"from": "Run", "to": 1}]. A text or boolean from also becomes the label shown for the number.
name, unitthe key, noneThe name and unit shown for the channel.

Suggested interval: 30 seconds. Credential: none.

What a value can be. Numbers of any width, booleans (0 or 1) and, with a value_map, text. A date, a structure, a byte string or an array is reported as a poll that is Down, with the type named, rather than guessed at. A node the server does not have, or one that cannot be read, is left unknown and Down with the OPC UA status code, such as BadNodeIdUnknown or BadNotReadable. A value of uncertain quality is reported and makes the sensor a Warning.

Why only security None, and what that means ​

The secured policies (Basic256Sha256 and the others, with Sign or SignAndEncrypt) are not offered. What it would take was looked at, and the sensor stops where it does for these reasons:

  • Crates. The two Rust OPC UA libraries are opcua and its maintained fork async-opcua, both under MPL-2.0. The first uses OpenSSL, which the project does not allow (deny.toml bans it). async-opcua implements the security policies with pure Rust cryptography (RustCrypto), and is maintained. It is the one candidate. Its licence is not on the list of licences this project accepts, so using it is a decision for the maintainers to make on purpose, not something a sensor change should do on the side; and it is a server and a client with the whole information model, many times the size of what a read needs.
  • Certificates. A signed or encrypted session needs an application certificate for the probe and a decision, for each server, about whether to trust the certificate it presents. That is a feature of its own (creating and storing the probe's key, showing a server's certificate to an administrator for approval, keeping the decision) and it belongs with the certificate pinning that the other sensors have, not inside one sensor.
  • User name login is only allowed by servers over an encrypted channel, and a password must not be sent over security None. Without the secured policies there is no login to offer.

So this sensor speaks the part of the protocol a read needs, by hand, over a plain connection: the UA TCP handshake, an open secure channel with no security, an anonymous session, a read, and closing both. The code is in crates/probeward-sensors/src/proto/opcua.rs, with no new dependency.

What it means for you: use the sensor against a server that offers security None with anonymous access, which many gateways and simulators do and many plant servers keep for monitoring on a closed network. Everything that crosses the network is readable and could be altered on its way: readings, not credentials, since there are none. For a server that requires a secured policy, the sensor reports the server does not offer anonymous access with security None. If you cannot enable security None on the server, an OPC UA to MQTT or Modbus gateway on the same network lets the MQTT and Modbus sensors read the same values.

On the target ​

An OPC UA server with an endpoint that has security mode None and allows anonymous users. Access control for what anonymous users may read is the server's: the sensor reads the Value attribute of the nodes you name and nothing else. It never writes, calls a method, browses or subscribes. Each poll opens a session and closes it again, so the server holds none between polls; a server with a small limit on sessions is kept well below it by one poll at a time.

Failures ​

MessageMeaning
a timeout (kind timeout), connection refused (kind unreachable)The server did not answer, or nothing listens on the port.
the server answered with something that is not OPC UA binary (kind protocol)The port is HTTPS, a web page or another service. OPC UA over HTTPS is not spoken.
the server refused the connection: BadTcpEndpointUrlInvalid (kind protocol)The host name in the endpoint URL is not one the server knows. Set server_name.
the server does not offer anonymous access with security None (kind auth_failed)The server requires a secured policy or a login; see above.
the server refused ActivateSession: BadIdentityTokenRejected and similar (kind auth_failed or protocol)The server's own refusal, with its status code.
<key>: BadNodeIdUnknown (0x80340000)A successful poll that is Down: there is no such node. Check the namespace index.
<key>: the value "..." is text with no entry in value_mapA successful poll that is Down.
<key>: the value is not a number (it is DateTime)A successful poll that is Down.

Verification ​

Run against the OPC PLC simulator (the open source one, in a container) with security None: the server state, a byte node of every server (ServiceLevel), the simulator's own nodes in its namespace, a node that does not exist (BadNodeIdUnknown, with the state still reported), a text value read without a map, and a port nobody listens on. The handshake, the reassembly of a session answer sent in several chunks, an opaque session token that has to be sent back unchanged, the server's error message, a server that offers no anonymous user policy, a web server on the port and one that never answers are also tested against a server written for the tests, which needs no lab. The decoding of values, the node identifiers and the sensor's rules are tested against scripted answers.

Not seen: any server other than the simulator, a server that chunks its answers (the reassembly is tested only against the test server), values of the kinds the sensor does not report, secured policies (not implemented), a server that limits its sessions.

The live test reads its target from the environment and says so and returns when it is not set:

VariableMeaning
PROBEWARD_TEST_OPCUA_HOSTThe server's address; it must allow anonymous users with security None.
PROBEWARD_TEST_OPCUA_PORTOptional: its port, 4840 when not set.
PROBEWARD_TEST_OPCUA_NODEOptional: a node that holds a number (ns=3;s=Name), which the test reads too.
sh
cargo test -p probeward-sensors --test industrial_live opcua -- --nocapture

AGPL-3.0-only