On this page
OPC UA client
The OPC UA client connects to an OPC UA server, browses nodes, reads values, and optionally creates subscriptions for data changes.
Compatible devices and models
| Device series / model examples | Connection requirements |
|---|---|
| PLCs, devices, SCADA systems or gateways exposing OPC UA | Configure endpoint, security policy, certificates or user authentication. Use the server namespace and NodeId and enable the required read/write or subscription permissions. |
Publish and identify the OPC UA node
First make the UA server read its underlying device. In KEPServerEX, configure the PLC Channel, Device and Tag, then check connectivity, type and quality in OPC Quick Client. This example uses the published simulator Ramp1: DA Item 模拟器示例.函数.Ramp1, UA NodeId ns=2;s=模拟器示例.函数.Ramp1. A PLC register such as D100 or DB1.DBW0 is not a replacement for that server NodeId.
- In KEPServerEX project properties, check OPC UA → Server Interface → Enable and choose the project’s anonymous-access policy. The following KEPServerEX6.6 vendor-help window shows the interface. Max connections limits client sessions; Allow anonymous login controls anonymous identity, not variable write permissions.
- In OPC UA Configuration Manager, enable a Server Endpoint on the intended interface. Record its complete URL, security policy and message-security mode;
49320is a common port. For remote clients, use a reachable interface address instead of127.0.0.1. A PLC’s built-in UA service requires its own engineering settings and published variables. - Configure users and certificate trust for that endpoint. For a secure connection, trust the gateway application certificate at the server and the server certificate at the gateway. Application trust and user node permissions are separate.
Read the same node in UaExpert
- Add a server in UaExpert. Under Custom Discovery, double-click Add Server and enter the actual endpoint. The local example uses
opc.tcp://127.0.0.1:49320.
- Expand the discovery result and select the matching endpoint and identity. This example uses the existing None - None endpoint and Anonymous, then connects. A server requiring signing, encryption or credentials needs the corresponding endpoint and authorized identity.
- Browse Objects → 模拟器示例 → 函数 → Ramp1 in Address Space. In Attributes, copy the complete NodeId and check DataType, ValueRank, AccessLevel and UserAccessLevel. The example has namespace
2, String identifier kind and identifier模拟器示例.函数.Ramp1.
- Right-click the Data Access View and select Add custom node…. Choose the server, namespace
2, String and the identifier. The resulting monitored row shows Ramp1, Int32, value99, Good and source/server timestamps.
Add the corresponding gateway variable
- Under Development Configuration → Collection Configuration → No channel, add an OPC UA client device. This example uses
Collect_OPC_UA, interval1000, enabled. Reading ordinary variables does not require device method calls.
- Under Plugin properties, enter the same Endpoint. For this None/None anonymous endpoint, leave credentials empty and keep Secure connection and Accept untrusted certificates off; enable data subscriptions. Match other endpoints to their actual security, certificates and users, then save.
- Under Protocol Debug → Node browser, find Ramp1 and refresh/read it. Check the complete NodeId, value, Good status and timestamp. This node declares Int32, ValueRank
-1(scalar), and AccessLevel/UserAccessLevel1(readable).
- Add an enabled Ramp1 variable with address
ns=2;s=模拟器示例.函数.Ramp1, Int32, Read Only and array length1.
In the address field editor, enter namespace 2, String and identifier 模拟器示例.函数.Ramp1, then confirm and fill back. Check the resulting ns=2;s= prefix; entering the complete NodeId again as the identifier would duplicate it.
- Save and inspect the live value, advancing collection time and empty error field. The row shows
91, Int32. Ramp1 changes automatically; compare matching times or the trend in UaExpert and the gateway.
| Address field | Rule |
|---|---|
| Namespace index | Decimal ns= index from this server’s current NamespaceArray. Recheck after rebuilding its configuration. |
| Identifier kind | Numeric is i=, String s=, Guid g=, Opaque b=. They identify different nodes. |
| Identifier | Preserve String case and punctuation, including semicolons; use Base64 for Opaque. Verify the complete NodeId after applying the editor. |
| Arrays/objects | Check ValueRank and the returned value first. A variable array length does not create server element nodes or PLC offsets. |
For an ordinary numeric point, start with subscriptions enabled, 1000 ms sampling and zero deadband. A nonzero deadband is absolute. Direct debugging reads the current source value. Disabling automatic subscriptions switches production collection to polling.
Open the plugin
Open Development Configuration → Collection Configuration, create a device, and select OPC UA client.
This plugin manages its connection in the device properties and does not use an ordinary TCP, UDP, or serial channel. Configure common variables through Collection Configuration.
Plugin properties
Connection and authentication
| Setting | Description |
|---|---|
| Endpoint URL | Default opc.tcp://127.0.0.1:49320. Enter the OPC UA server endpoint. |
| Username | Username required by the OPC UA server. Leave empty when the endpoint allows anonymous access. |
| Password | Password for the OPC UA user. Do not expose it in screenshots or logs. |
| Use Secure Endpoint | Enables a secure OPC UA endpoint according to the server policy. |
| Accept Untrusted Certificates | Temporary commissioning option. In production, configure the trust chain instead. |
| Client Certificate Name | Client certificate selected from Certificate Management. Required by the endpoint’s security policy. |
Subscription
| Setting | Description |
|---|---|
| Data Change Trigger | Default Status or Value Changes. Select which data changes trigger a notification. |
| Enable Data Subscriptions | Enables subscription updates. Disable only when the project uses polling. |
Protocol and data format
| Setting | Description |
|---|---|
| Application Name | Default TGateway_OPC_UA_Master. The OPC UA application identity shown to the server. |
| Load Server Data Types | Loads the server’s node data types so variables can use the correct runtime type. |
| Use Source Timestamp | Uses the source timestamp supplied by the OPC UA server when enabled. |
Alarms and conditions
| Setting | Description |
|---|---|
| Subscribe alarm events | Disabled by default. Receives device alarm, recovery, and acknowledgment states through device event forwarding. |
| Event node | Default i=2253. Use the NodeId of the object providing event notifications. |
| Condition capacity | Default 4096. Bounds retained conditions and branches; exceeding it reports a gap and suspends control. |
| Allow alarm acknowledgment | Disabled by default. Device method calls and current caller permissions must also allow control. |
Conditions refresh after connection or reconnection. Old events cannot control alarms before refresh completes. Invoke Acknowledge Device Alarm under special methods using the latest event’s Generation, ConditionId, BranchId, and EventId. Confirm=false performs Acknowledge; Confirm=true performs Confirm when the device condition supports it. Stale generations, incorrect branches, and obsolete EventIds are rejected. Verify the device’s new condition state after a successful call.
Runtime and grouping
| Setting | Description |
|---|---|
| Sampling / Polling Interval (ms) | Default 1000 ms. Requests monitored-item sampling in subscription mode; the server may revise it. With subscriptions disabled, it schedules polling groups. It does not set the subscription publishing period. |
| Session Keep-alive Interval (ms) | Default 3000 ms. Session KeepAlive interval; 0 selects 5000 ms rather than disabling KeepAlive. |
| Deadband | Default 0. A nonzero value requests an absolute numeric deadband, not a percentage. At zero, the client sends no custom data-change filter. |
| Max Group Size | Default 500. Maximum nodes grouped in one read or subscription operation. |
Data Change Trigger options are Status Changes, Status or Value Changes, and Status, Value or Timestamp Changes. Choose the last option when a timestamp-only change must be reported.
Address rule
Regular variables
Use the OPC UA NodeId as the address of a regular collection variable, for example ns=2;s=Channel1.Temperature. Browse and read the node in device debug first, then copy the complete namespace and identifier.
OPC UA method variables
To let an external system call a method on the OPC UA server, create a dedicated variable under the OPC UA device and configure it as follows.
| Setting | Required value |
|---|---|
| Variable name | Use a name that identifies the action, such as Start method or Recipe switch method. External RPC requests use this name to locate the method variable. |
| Other Method | Select Call an OPC UA method in the plugin method list. |
| Variable address | Enter a standard JSON array containing the object and method NodeIds, for example ["ns=2;s=Machine1","ns=2;s=Machine1.Start"]. The first element must be the object that provides the method; the second must be the method node. |
| Read/Write Permission | Select Write Only. A control method must not enter periodic collection, which could trigger it repeatedly. |
| RPC Write Enable | Enable it. Web API, MQTT, and other external entries reject the call when this permission is disabled. |
| Write Check | Disable it. A method call is not a readable point; verify it from the RPC result and device state. |
After saving the variable, provide the external RPC value in the same order as the OPC UA method’s InputArguments. The outer JSON array is the argument list.
| Method inputs | RPC variable value |
|---|---|
| No input arguments | [] |
| One scalar argument | [123] |
| Two arguments | [123, "start"] |
| One array argument | [[1, 2, 3]] |
The client reads the standard InputArguments metadata from the server and converts each JSON value to the declared OPC UA data type. All output arguments are returned in order as a JSON array; a method without outputs returns an empty array.
Remote-control safety
Bind method variables only to control methods approved for the site. Grant the integration account only the required variable-write permission, and commission the call with an object and parameters that cannot affect production.
External RPC call
Web API
Call /api/gatewaywritevariablecontroller/setvariablevalue. Organize the request as device name → method variable name → input argument array:
{
"OPC device": {
"Start method": [123, "start"]
}
}The gateway checks that the variable exists, is writable, allows RPC writing, and does not belong to a paused device before calling the OPC UA method. The variable result’s Content contains the server output-argument array. For a failed call, inspect ErrorMessage, the RPC log, and the device log.
MQTT and other entries
MQTT RPC and every other entry connected to the variable RPC service use the same method variable. After the target RPC topic or script resolves the device name, variable name, and JSON argument array, it invokes the same OPC UA method. See Reverse RPC for topic, authentication, and response rules.
Device debug
Open Development Configuration → Collection Configuration, select the OPC UA device, open Protocol Debug at the top of the workspace.
Node browser
Follow the Ramp1 example above to select and read a variable node. Its complete NodeId, declared type and access rights determine the variable settings.
Browse the server namespace, select a node, and read it before importing variables. Use write operations only for approved writable nodes.
Debug checklist
- Confirm the endpoint URL and security mode.
- Browse the namespace and copy the exact
NodeId. - Read one node and compare its value and data type with the server tool.
- Create a subscription only after single-node reading works.
Functions
| Function | Purpose |
|---|---|
| Browse nodes | Browse the OPC UA namespace and inspect NodeId, data type, value, status, and timestamp. |
| Read and write nodes | Read one selected node; write only to a server-approved test node. |
| Export and import | Export selected nodes to a variable file or import them into the current device. |
| Subscription management | Create, inspect, or cancel subscriptions for selected NodeIds. |
Subscription and trust checks
Sampling / Polling Interval (ms) requests a monitored-item sampling interval; the server can revise it. It is not the subscription publishing period. Session Keep-alive Interval (ms) set to 0 uses 5000 ms rather than disabling KeepAlive. Nonzero deadband requests an absolute numeric deadband, not a percentage.
Status Changes, Status or Value Changes, and Status, Value or Timestamp Changes select the changes to observe. The current client submits this custom filter only with a nonzero deadband. With zero deadband, no custom filter is sent. Compare direct reads against subscriptions: with deadband 10, 1234 → 1239 can appear in a direct read without a notification, while 1250 crosses the threshold. Status-only filtering does not notify ordinary value-only changes.
The maximum group size chunks reads and automatic subscription organization; repeated NodeIds in a group can be deduplicated. More groups increase session work. Use Source Timestamp must be checked against correct server and gateway clocks. After writes, read the source node again; shared duty-cycle/write-priority fields do not establish an automatic read after every OPC UA write.
Accept Untrusted Certificates only permits the untrusted-certificate validation case. It does not waive expiry, application-URI, or host-name errors. Establish application certificate trust on both sides and select the proper user identity separately. An endpoint URL must include the actual scheme, host, port, and required path.
Method calls
In Method call, enter the object NodeId and method NodeId, which can be copied from Node browse. Add arguments in the order declared by the device. Each row accepts a string, number, Boolean, structure or array JSON, or Null, and can be moved or removed. For a method without input arguments, call it without adding rows.
Numeric input retains its original JSON text without conversion through a browser floating-point value. Enter a structure or array as one JSON argument. The selected format controls editing; the actual OPC UA types and argument count follow the device’s InputArguments declaration. Confirm the device, nodes and complete arguments before calling. Methods may change device state, so special-method execution permission and enabled device method calls are required. Results preserve output argument order; rejections and timeouts are not retried automatically.
You can edit up to 128 input arguments. The complete parameter JSON must fit within 64 KiB (65,536 UTF-8 bytes), including both NodeIds, array punctuation, and string escapes. Some characters use multiple bytes. The page rejects oversized arguments before confirmation; reduce the arguments and try again.
Alarm conditions and acknowledgement
Open Alarms and events in protocol debugging. First enable alarm-event subscription in the device properties and select an event-capable node. The list shows source, message, severity, active/recovered state, acknowledgement, confirmation, and time. Expand a row to inspect its condition, branch, and event identity.
Search by source, message, or condition details; sort, paginate, and enable automatic refresh as needed. Refresh reads the current condition snapshot. If subscription is disabled, the device is unavailable, refresh is incomplete, or a gap is reported, check the event node, subscription, and condition capacity.
Control requires Allow alarm acknowledgement, the device’s Allow method calls, and dangerous-debug permission. Select Acknowledge alarm, then Confirm alarm only when the server requires that second step. An optional comment accompanies the operation. Read-only users can inspect conditions without control actions.
The confirmation dialog keeps the selected event identity. After reconnection, a newer event, or a target change invalidates it, refresh and review the condition again. After a successful call, check the server’s subsequent state. Acknowledgement does not clear the physical cause or acknowledge the gateway’s own alarm list.
Verify the configuration
- Browse to a known
NodeIdand read it. Confirm that the status code is good. - Change the approved test node on the server and confirm that the read result or subscription value updates.
- Import a small set of test nodes and check NodeId, data type, value, and timestamp.
- When subscriptions are enabled, confirm Sampling / Polling Interval, Data Change Trigger, deadband, and Max Group Size.
- Write only to a server-approved test node, then read it again.
- Call a non-production test method first and verify the object NodeId, method NodeId, and input-argument count.
- Invoke the method once from the variable write dialog and once from the intended external RPC entry. Compare the output arguments, RPC log, and server-side result.
Troubleshooting
| Symptom | Check |
|---|---|
| Cannot connect | Endpoint URL, server availability, firewall, security policy, certificate trust, and username/password. |
| Certificate rejected | Identify the rejecting side. A client rejection requires checking the server certificate and local trust; a server rejection requires checking its trust in the client application certificate. Check validity and application URI on both sides. |
| Browse returns no nodes | Session security, user permissions, namespace selection, and the starting NodeId. |
| Read returns an error | Exact NodeId spelling, namespace index, node access permission, and server data type. |
| Subscription does not update | Enable Data Subscriptions, Data Change Trigger, deadband, Sampling / Polling Interval, and server subscription limits. |
| Value type is wrong | Enable Load Server Data Types and compare the variable data type with the OPC UA node type. |
| Call an OPC UA method is missing | Confirm that the device uses the current OPC UA client plugin and restart TGateway after updating the application. |
| Input-argument count is invalid | The outer RPC array is the argument list. For one array argument, use a nested array such as [[1, 2, 3]]. |
| Input type does not match | Compare the payload with the method’s InputArguments data types and value ranks, and confirm that the server publishes the standard metadata. |
| Method is invalid or not executable | Check that the object owns the method, the OPC UA user can execute it, and the method is executable. |
| Method runs repeatedly | Set the method variable to Write only so periodic collection cannot invoke it. |
| External RPC is rejected | Enable RPC writing on the method variable, confirm that the device is not paused, and grant the integration account variable-write permission. |
Related links
- Collection Configuration: Devices, variables, certificates, and common debug entry.
- Certificate Management: Manage client and CA certificates.
- Reverse RPC: Configure Web API, MQTT RPC, permissions, and log verification.
- Plugin Manual Index: Other collection and data-forwarding plugins.

















