OPC UA Server
OPC UA server starts and runs a custom OPC UA server on your infrastructure. Use it to construct a declarative information model out of folders, objects, and variables, and attach logic to process data reads and writes from external OPC UA clients.
This connector requires instance creation before you can configure network ports, map variable schemas, and manage the server lifecycle.
Variable interaction types
Variables are defined inside objects within the server's information model. Their operational behavior is governed by three distinct configuration categories:
Getters (read-only for clients) – Managed internally by your logic. External OPC UA clients can read these values but cannot modify them. Update a getter variable by calling
setValuewhenever its real-world state changes.Setters (write-only for clients) – Designed to ingest data updates transmitted from external OPC UA clients. When a client modifies a setter node, the server triggers the
onSetevent handler. After your logic processes the data, you must invokesetValueto finalize the node synchronization.Requestors (read-on-demand for clients) – Variables whose data payloads are not held in continuous server cache memory. When a client reads a requestor node, the server fires the
onRequestevent handler. Your logic must then immediately calculate or fetch the data value and provide it to the server usingsetValue.
Server lifecycle
create
Creates an unconnected OPC UA server instance and maps out its information model structure.
Parameters
options
objects
An array defining folders, objects, and variables inside the server information model. Each node requires a path and a type (folder or object), along with getters, setters, or requestors type maps. An object can optionally define an integer offset to assign fixed numeric nodeIds to the object and its getter variables.
array
port
The TCP port where the server listens for inbound connections. Separate parallel server instances must use distinct port numbers. Default 4840.
integer
allowAnonymous
Controls whether external clients can connect without credentials. When false, clients must authenticate with the credentials of an integration user. Default true. See Protocol and encryption for the supported security level.
boolean
Output
Returns the name of the created instance.
Example
start
Initializes and starts the underlying OPC UA server engine, exposing the endpoint to network traffic.
Parameters
None.
Output
Returns a string containing the primary endpoint connection URL (for example, opc.tcp://localhost:4841/UA/HeisenwareOPCUAServer), including when the server is already running. Throws an error if starting fails.
stop
Shuts down the active server engine and releases occupied network sockets.
Parameters
None.
Output
Returns nothing on a successful shutdown. Throws an error if stopping fails.
isStarted
Queries whether the underlying server engine is running and accepting client connections.
Parameters
None.
Output
Returns true if the server engine is active, or false if it is not.
delete
Removes the instance and its configuration.
Irreversible action
Deleting an instance removes its configuration. To run the server again, you must create a new instance.
Parameters
None.
Output
Returns true upon removal.
Data operations and events
setValue
Sets a new data value for a specific variable node on the server. This function updates getter nodes and serves as the response within your custom onSet and onRequest event scripts. The value must match the declared type, see Data type validation.
Parameters
variablePath
The destination path targeting a specific node variable, formatted as path/to/object:variableName.
string
value
The data payload to store inside the node variable. Must match the declared schema data type.
any
Output
Returns true if the node variable updates successfully, or false if the path, variable, or data type is invalid (the reason logs as a warning).
Example
onSet
Registers an event callback executed whenever an external OPC UA client writes a new value to a designated setter variable node.
Parameters
variablePath
The path of the setter variable node to monitor, formatted as path/to/object:variableName.
string
listener
The callback evaluated when a write occurs. Receives the updated value sent by the client.
callback
Output
Returns 'subscribed' when successfully registered.
Example
onRequest
Registers an event callback executed whenever an external OPC UA client attempts to read a designated requestor variable node on-demand.
Parameters
variablePath
The path of the requestor variable node to monitor, formatted as path/to/object:variableName.
string
listener
The callback evaluated when an on-demand read request arrives.
callback
Output
Returns 'subscribed' when successfully registered.
Example
onServerUpdate
Registers a global diagnostic event callback executed whenever any variable node value updates on the server via setValue. Notifications are throttled, see Server update throttling.
Parameters
listener
The callback executed on a value update. Receives an epoch millisecond timestamp and the modified variable path string.
callback
Output
Returns 'subscribed' when successfully registered.
Example
Complete usage example
The steps show how to configure and run the server based on the model defined in the create example.
Create the server
Create the server instance with the desired information model, as shown in create.
Tips and tricks
Server update throttling
The internal notification processor throttles onServerUpdate events to a maximum of once per second. Rapid successive setValue updates apply to memory values instantly, but listeners tracking global server updates receive notifications aggregated at one-second intervals.
Protocol and encryption
The local server operates with unencrypted communication profiles (SecurityPolicy.None and MessageSecurityMode.None). It does not support custom certificates or encrypted transport envelopes. Manage outer network security boundaries when routing client traffic across public infrastructure.
Data type validation
The underlying engine strictly validates values passed to setValue against the information model schema. Input data types must comply with these parameters:
boolean
Primitive JavaScript boolean values (true or false).
string, date
Textual strings. Dates must conform to standard ISO 8601 syntax.
integer, bigint, float, double, timestamp
Numeric values.
arrayBoolean, arrayInteger, arrayString, etc.
Standard arrays containing matching primitive types.
Last updated
Was this helpful?