Skip to main content

OPC-UA Node

You can communicate directly with external OPC-UA servers (Kepware, Ignition, other gateways) through community nodes like node-red-contrib-opcua. The same nodes are used to connect to the OPC-UA server of the gateway itself (opc.tcp://127.0.0.1:12000/opcua, NodeId ns=2;s=...).

Connecting to the built-in OPC-UA server

Copy the TCP Endpoint URL and NodeId exactly from the OPC UA Server › Server Information tab in the screen menu. For more details, refer to Using OPC UA Server.


1. Node Types (node-red-contrib-opcua)​

NodePurpose
OpcUa-EndpointServer connection information (host/port/security/auth) — created once and shared across other nodes
OpcUa-ItemSingle node definition — converts nodeId into input
OpcUa-ClientMain operation node for Read / Write / Browse / Method call
OpcUa-SubscribeChange event (MonitoredItem) subscription — receive via push without polling
OpcUa-EventOPC-UA Alarm & Event subscription

2. Creating an Endpoint​

Double-click the OpcUa-Client node → pencil icon next to Endpoint → New endpoint:

FieldValue (Based on built-in gateway server)
Endpointopc.tcp://127.0.0.1:12000/opcua
Security PolicyNone (Internal) or Basic256Sha256 (External Operation)
Security ModeNone / Sign / Sign & Encrypt
LoginUsername/Password from the OPC UA server screen or Anonymous (if permitted)

3. Read / Write Patterns​

inject ─▶ OpcUa-Item (nodeId, msg.payload type) ─▶ OpcUa-Client (READ/WRITE) ─▶ debug

OpcUa-Item:

FieldValue
Itemns=2;s=SITE_00001.OPC_00303.TAG_TEST_00042
DataTypeInt32 (Must match the actual tag data type — otherwise results in BadTypeMismatch)

OpcUa-Client:

FieldValue
ActionREAD or WRITE
EndpointEndpoint created above

When performing a WRITE, fill values like msg.payload = 9999 using change before the OpcUa-Item node.


4. Subscribe — Receiving Changes Without Polling​

Subscribe is significantly more efficient than polling (periodic read). There is no traffic when there are no changes, and data arrives in microseconds.

inject (once after deploy) ─▶ OpcUa-Item ×N ─▶ join (배열) ─▶ OpcUa-Subscribe ─▶ debug / function

OpcUa-Subscribe:

FieldValue
ActionSUBSCRIBE
Interval100 ms recommended (minimum cycle for the server to notify the client)
Queue size10 (Buffer for server congestion)

Incoming messages include msg.payload (value) + msg.topic (NodeId) + msg.timestamp.


5. Browse — Automatic Node Tree Exploration​

Used when you need to identify "which NodeIds exist" in environments with hundreds or thousands of nodes, such as KEPServerEX.

inject ─▶ OpcUa-Client (action=BROWSE, msg.payload="ns=2;i=85") ─▶ debug

The response is an array of [ {nodeId, browseName, displayName, ...} ] of child nodes. This can be processed via function to create an automatic registration flow.


6. Common Pitfalls​

SymptomCause / Solution
BadIdentityTokenInvalidUntrusted user/password or certificate. Trust the client certificate in the server console
BadTypeMismatchDataType of OpcUa-Item differs from the actual node type
Frequent Connection Lost messagesHost domain in Endpoint URL differs from the certificate CN — reissue certificate or match URL host to certificate CN
Subscribe triggers only onceOpcUa-Subscribe only needs to be "registered" once. Use the once after deploy option for inject

7. Next Steps​