Class: OpcUaTransport
Defined in: livelink.clients/livelink.agent/sources/data/transports/OpcUaTransport.ts:304
Transport that subscribes to variables on an OPC UA server over opc.tcp:// and forwards each
value change as an event on the node's channel — the node id, or the readable alias given in
its OpcUaNodeSpec. Like MQTT and unlike Event Hubs, that channel is a genuine routing key
a mapping can select on.
This is the classic client/server profile, which is what a PLC whose firmware predates PubSub
exposes. If the plant already bridges OPC UA to MQTT — via OPC UA PubSub over MQTT, Telegraf's
inputs.opcua, Kepware, Ignition — point the mqtt transport at that broker instead: one hop
fewer, and no OPC UA client to keep alive next to the scene.
Each event's payload is { node_id, value, status } and its source_timestamp is the server's
own clock. Samples whose status is Bad carry no meaningful value and are dropped, logging once per
node rather than at every publication.
Requires the optional dependency node-opcua-client (loaded lazily on
OpcUaTransport.start). opc.tcp is raw TCP, so this transport is Node.js only — in a
browser the lazy import is what fails, with the same message as a missing install.
A secured connection (security_mode other than "None") makes node-opcua generate a
self-signed client certificate under a certificates/ folder on first use. The server has to
trust it — on a Siemens PLC, that is a manual step in the web interface, and the failure everyone
hits first.
Implements
Constructors
Constructor
new OpcUaTransport(config: {
endpoint_url: string;
nodes: (string | OpcUaNodeSpec)[];
publishing_interval?: number;
sampling_interval?: number;
queue_size?: number;
security_mode?: "None" | "Sign" | "SignAndEncrypt";
security_policy?: string;
username?: string;
password?: string;
application_name?: string;
max_retry?: number;
}, sink: EventSink): OpcUaTransport;
Defined in: livelink.clients/livelink.agent/sources/data/transports/OpcUaTransport.ts:357
Parameters
| Parameter | Type | Description |
|---|---|---|
config | { endpoint_url: string; nodes: (string | OpcUaNodeSpec)[]; publishing_interval?: number; sampling_interval?: number; queue_size?: number; security_mode?: "None" | "Sign" | "SignAndEncrypt"; security_policy?: string; username?: string; password?: string; application_name?: string; max_retry?: number; } | - |
config.endpoint_url | string | Endpoint of the OPC UA server, e.g. opc.tcp://plc.example.com:4840. |
config.nodes | (string | OpcUaNodeSpec)[] | Nodes to monitor. A bare string is a node id whose channel is that same node id; use the OpcUaNodeSpec form to alias it to a readable channel. |
config.publishing_interval? | number | How often the server publishes the samples it has collected, in milliseconds. Defaults to 1000. This is the latency floor of the whole ingestion: sampling faster than this only fills the queue. This is a request: the server answers with the interval it will actually publish at, and that is the one that holds. Most servers refuse to go below 50 ms — node-opcua's own server clamps there, and caps at one minute — so asking for less buys nothing. A request the server revises upward is logged once rather than absorbed silently, since everything downstream of a halved sample rate looks like a bug elsewhere. |
config.sampling_interval? | number | How often the server samples the monitored nodes, in milliseconds. Defaults to OpcUaTransportConfig.publishing_interval, i.e. one sample per publication. Revised by the server the same way the publishing interval is, and logged the same way: a node whose underlying device cannot be read faster comes back with its own minimum, whatever this asks for. |
config.queue_size? | number | How many samples the server buffers per node between two publications. Defaults to 1, which keeps only the latest — the right choice for telemetry driving a scene. Raise it to receive every sample of a node sampled faster than it is published. |
config.security_mode? | "None" | "Sign" | "SignAndEncrypt" | Message security to negotiate. Defaults to "None", or to "SignAndEncrypt" when a OpcUaTransportConfig.security_policy other than "None" is named. |
config.security_policy? | string | Security policy to negotiate, by short name ("Basic256Sha256", "Aes128_Sha256_RsaOaep", ...) or by full policy URI. Defaults to "None", or to "Basic256Sha256" when a OpcUaTransportConfig.security_mode other than "None" is named. The two must agree: either both are "None", or neither is. |
config.username? | string | User name to authenticate with. Omitted = connect anonymously. |
config.password? | string | Password that goes with OpcUaTransportConfig.username. |
config.application_name? | string | Application name announced to the server, and carried by the client certificate generated for a secured connection. Defaults to "livelink-agent". |
config.max_retry? | number | How many times to retry the connection before giving up. Defaults to 3. Deliberately bounded: sources are started sequentially and awaited, so a transport retrying forever would hang the whole ingestion rather than report. A failed start surfaces on on-error and is retried by the next session to bind, which is the loop that actually survives a PLC being down at boot. The same budget governs the automatic reconnection after an established connection drops. |
sink | EventSink | - |
Returns
OpcUaTransport
Methods
start()
start(): Promise<void>;
Defined in: livelink.clients/livelink.agent/sources/data/transports/OpcUaTransport.ts:370
Connect to the server, open a session and subscribe to every configured node.
Returns
Promise<void>
Implementation of
stop()
stop(): Promise<void>;
Defined in: livelink.clients/livelink.agent/sources/data/transports/OpcUaTransport.ts:413
Terminate the subscription, close the session and disconnect. Safe when never started, and safe when only part of the connection was ever established.
Returns
Promise<void>