Skip to content

OPC-UA Source and Sink Connector ​

stream sourcelookup table sourcesink

The OPC-UA connector connects to OPC Unified Architecture (OPC-UA) servers using the binary TCP protocol (opc.tcp://).

The connector runs in pure Rust without external C libraries or companion containers.

Architecture and Security ​

  • Protocol: OPC-UA Binary TCP (opc.tcp://).
  • Security Policy: SecurityPolicy#None.
  • Authentication: Anonymous identity tokens and Username / Password authentication.
  • Dependencies: Zero C library dependencies.

Stream and Table DDL Syntax ​

Stream Source ​

sql
CREATE STREAM opcua_sensors () WITH (
    TYPE="opcua",
    ENDPOINT="opc.tcp://192.168.1.100:4840",
    INTERVAL="100ms",
    TIMEOUT="2000ms",
    USERNAME="operator",
    PASSWORD="password123",
    NODES='[
        {"name": "temperature", "nodeId": "ns=2;s=Device1.Temperature"},
        {"name": "pressure", "nodeId": "ns=2;s=Device1.Pressure"},
        {"name": "machine_state", "nodeId": "ns=2;i=1004"}
    ]'
)

Lookup Table ​

Query OPC-UA variables on-demand to enrich incoming event streams:

sql
CREATE TABLE machine_metadata () WITH (
    TYPE="opcua",
    ENDPOINT="opc.tcp://192.168.1.100:4840",
    NODES='[
        {"name": "serial_number", "nodeId": "ns=1;s=Device.SerialNumber"},
        {"name": "firmware_version", "nodeId": "ns=1;s=Device.Firmware"}
    ]'
)

Configuration Parameters ​

Source and Table Parameters ​

PropertyTypeDefaultDescription
endpointstringrequiredOPC-UA server URL (e.g. opc.tcp://192.168.1.100:4840).
intervalstring"100ms"Polling frequency for streaming sources (e.g. "50ms", "1s").
timeoutstring"1000ms"Network and request timeout.
usernamestringoptionalUsername for user token authentication.
passwordstringoptionalPassword for user token authentication.
nodesJSON array / stringrequiredList of node specifications to poll.

Node Specification Schema ​

Each element in nodes defines:

FieldTypeDefaultDescription
namestringrequiredKey name in the emitted JSON record.
nodeIdstringrequiredOPC-UA NodeId formatted string.

Supported NodeId Formats ​

The connector parses standard OPC-UA NodeId string representations:

Identifier TypeFormatExample
Numericns=<namespace>;i=<integer> or i=<integer>ns=2;i=1001 or i=2258
Stringns=<namespace>;s=<string>ns=2;s=Device1.Sensors.Temp
GUIDns=<namespace>;g=<uuid>ns=2;g=72962b91-fa75-4ae6-8d59-5f80f68d3744
ByteStringns=<namespace>;b=<base64>ns=2;b=YWJjZA==

Variant Decoding and Float Validation ​

The connector decodes OPC-UA Variants into JSON types:

  • Primitive Types: Boolean, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float, Double, String, DateTime, Guid, ByteString.
  • Float Validation: The connector checks Float and Double values for NaN and Infinity. It rejects invalid values to prevent SQL evaluation errors.

OPC-UA Sink Action (Control Closed Loop) ​

Write control setpoints and state changes to OPC-UA servers:

json
{
  "id": "set_valve_position",
  "sql": "SELECT target_valve_pos FROM pid_stream WHERE target_valve_pos IS NOT NULL",
  "actions": [
    {
      "opcua": {
        "endpoint": "opc.tcp://192.168.1.100:4840",
        "nodeId": "ns=2;s=Device1.Actuators.Valve1",
        "field": "target_valve_pos"
      }
    }
  ],
  "options": {
    "onError": "dlq",
    "dlq": {
      "action": {
        "mqtt": {
          "server": "tcp://127.0.0.1:1883",
          "topic": "rekuiper/dlq/opcua_errors"
        }
      }
    }
  }
}

Dead-Letter Queue (DLQ) Integration ​

When an OPC-UA write fails with permanent status codes:

  • BadNodeIdUnknown (0x80340000)
  • BadTypeMismatch (0x803C0000)
  • BadNodeNotInHierarchy (0x80350000)
  • BadNotWritable (0x803B0000)

The connector classifies the failure as a permanent delivery error. It sends the output event to the dead-letter queue under DlqStage::SinkDelivery.

rekuiper is open source (Apache-2.0 / MIT) · For an all-in-one MQTT broker with embedded rekuiper rules, see IndraMQTT.