December 17, 2025
December 17, 2025

OPC UA traditionally uses a client-server communication model where clients request data from servers. While this works well for closed-loop industrial automation, it doesn't scale effectively for Industrial IoT scenarios involving thousands of devices and cloud platforms. This tutorial explains OPC UA PubSub—an extension that enables publish-subscribe communication—and demonstrates building an OPC UA over MQTT application using Node.js.
Understanding OPC UA PubSub is essential for architects designing scalable industrial IoT systems that connect factory equipment to cloud analytics platforms.
Traditional OPC UA uses a request-response communication pattern. An OPC UA server exposes information about devices, machines, or processes. When an OPC UA client needs to retrieve or update information, it sends browse, read, write, or method call requests to the server, which responds accordingly.
This direct, synchronous communication between client and server works well in closed-loop command and control scenarios where the total number of connections remains relatively small.
However, Industrial IoT introduces different requirements. IoT architectures integrate data from many components across Operational Technology (OT) and Information Technology (IT) domains through centralized platforms like the cloud. In these scenarios, the client-server approach faces significant challenges:
Scalability Issues: As connected components increase rapidly, the client-server model cannot scale to meet connectivity demands. Each client requires an individual session with the server, consuming resources.
Integration Barriers: Smart devices and cloud-based analytics systems that don't understand OPC UA protocols struggle to access data from OPC UA-enabled production equipment. Bridging this gap requires additional gateway components.
These limitations prompted the OPC Foundation to develop a solution that better fits Industrial IoT architectures.
Before explaining OPC UA PubSub, it's important to clarify potential confusion around subscription terminology.
The original OPC UA client-server specification includes a subscription feature for monitoring changes on servers. This is different from the Part 14 PubSub specification.
In the client-server model, each OPC UA client creates subscriptions to an OPC UA server:
Monitored Item Subscriptions: A client requests the server to monitor specific variables. When values change, the server pushes updates to the client.
Event Notifier Subscriptions: A client requests the server to watch for specific events. When events occur, the server sends notifications to the client.
However, these subscriptions still require individual sessions between each client and server—they remain strictly client-server communication, not true publish-subscribe.
When this tutorial mentions PubSub, it refers exclusively to the Part 14 PubSub specification, not the built-in subscription features of client-server communication.
OPC UA PubSub (Part 14 of the OPC UA specification) extends OPC UA to support publish-subscribe communication patterns instead of request-response patterns.
Rather than responding to individual client requests, an OPC UA server can push data to multiple data consumers who have subscribed to that data stream through an intermediary communication system.
This achieves the one-to-many and many-to-one communication essential for Industrial IoT with extremely low resource consumption. The sender no longer communicates with all participants individually—the intermediary handles distribution.
In OPC UA PubSub:
Publishers: Devices or systems that send OPC UA information to an intermediary communication system. In particular, an OPC UA publisher sends data without knowing which subscribers receive it.
Subscribers: Systems that receive information from the intermediary. Subscribers express interest in specific data types without knowing which publishers produce it.
Due to the decoupled nature of publish-subscribe patterns, the number of subscribers doesn't influence how publishers produce data. Publishers simply publish; the middleware handles distribution.
Most cloud platforms use publish-subscribe patterns for managing device-to-cloud and cloud-to-device messages. OPC UA PubSub enables OPC UA devices and applications to transmit factory floor data directly to cloud-hosted data services for analytics.
Importantly, OPC UA PubSub doesn't mean using an OPC UA client gateway that collects data from servers and publishes to the cloud. It means OPC UA servers implement PubSub functionality and publish information directly to cloud platforms.
Like other OPC UA specifications, OPC UA PubSub is an abstract specification not bound to a particular messaging system. However, it provides specifications for communication parameters and transport protocol mapping.
This abstract definition allows OPC UA PubSub to transport different information types through different networks:
OPC UA client-server uses a service-oriented approach where participants communicate by providing services to each other—requests and responses.
OPC UA PubSub uses a message-oriented approach where participants communicate by exchanging messages through middleware:
The OPC UA PubSub specification doesn't define specific middleware implementations. Instead, it describes two types of middleware it supports.
In brokerless form, OPC UA PubSub relies on network infrastructure itself to deliver messages to receivers. The message-oriented middleware is the network infrastructure—routers, switches, and bridges.
Publishers and subscribers use datagram protocols like UDP or UADP (UDP multicast combined with UA binary encoding). Even though one-to-many message distribution is achieved, it's not through a third-party message broker. Instead, publishers multicast UA binary encoded messages using UDP.
Standard Network Equipment: Requires only standard network infrastructure with no additional software components like brokers
Reduced Latency: Message delivery is direct without software intermediaries, providing lower latency and overhead
Efficient Resource Usage: No broker resources consumed
Brokerless OPC UA PubSub using UADP (or future Ethernet APL) suits:
In broker-based form, the primary middleware component is a message broker. No application speaks directly to other applications—all communication passes through the broker, which routes messages based on business criteria.
Subscribers and publishers use standard messaging protocols like MQTT or AMQP to communicate with the broker. The broker distributes JSON encoded publisher messages to subscribed receivers.
The message broker can reside in the cloud or anywhere visible to both publishers and subscribers.
Location Independence: Publishers and subscribers don't need to be directly addressable. They can be anywhere with broker access.
Massive Scalability: Fanout architecture supports very large subscriber lists across multiple networks
Flexible Routing: Brokers can implement complex routing logic and even chain to other brokers
Cloud Integration: Natural fit for cloud-based analytics and monitoring platforms
Broker-based OPC UA PubSub using MQTT or AMQP suits:
Understanding the complete data flow from publisher to subscriber reveals how OPC UA PubSub works under the hood.
PubSub Connection Creation: The first step defines transport protocol parameters—for example, MQTT protocol and broker URL address.
Dataset Collection: Data to be published is collected from the server's address space. This collection is called a dataset—a list of name-value pairs representing variable values or events. A dataset collector pulls this dataset from the OPC UA server's address space according to configuration.
Published Dataset Creation: The collected dataset is placed in a container called a published dataset. This container includes dataset metadata that describes the contents and semantics of the dataset, helping subscribers interpret published information the same way as the publisher.
Dataset Message Creation: A dataset writer component takes the dataset and creates a dataset message. The dataset writer refers to dataset metadata to structure the message correctly, matching field order in metadata with value order in messages. Each dataset message includes a dataset writer ID for identification.
Dataset Message Formats: Dataset messages can use different formats:
Network Message Creation: A writer group component combines one or more dataset messages into a network message. Network messages include additional header information like publisher ID, group writer ID, and sequence numbers. This is the actual message transmitted to the middleware.
Network Message Reception: Subscribers receive network messages from the middleware (broker or network infrastructure).
Dataset Message Extraction: The subscriber extracts individual dataset messages from the received network message.
Dataset Interpretation: Using the dataset metadata, the subscriber interprets the dataset message fields, mapping them to local variables or processing logic.
Data Processing: The subscriber processes the received data according to its application logic—displaying on dashboards, storing in databases, triggering alerts, or feeding analytics engines.
Let's demonstrate building an OPC UA PubSub application that transmits OPC UA data over MQTT using Node.js. This example shows the broker-based approach with JSON encoding.
Install Node.js and the required OPC UA PubSub packages:
bash
npm install node-opcua
npm install mqtt
These packages provide the libraries needed to implement both OPC UA server functionality and MQTT communication.
Build a publisher that reads sensor data and publishes it via MQTT:
Build a subscriber that receives and processes the published data:
Start the publisher application first—it begins reading sensor data and publishing to the MQTT broker. Then start the subscriber application. The subscriber connects to the broker, subscribes to the temperature topic, and begins receiving temperature updates.
Monitor the subscriber output to verify temperature values are successfully transmitted from the OPC UA publisher through MQTT to the subscriber. The data flows seamlessly even though the publisher and subscriber have no direct connection—the MQTT broker handles all routing.
From this foundation, you can extend the application to:
Your application requirements determine which OPC UA PubSub approach to use:
Use Brokerless (UADP) when:
Use Broker-Based (MQTT/AMQP) when:
Many industrial architectures use both approaches—UADP for local control systems and MQTT for cloud connectivity.
OPC UA PubSub doesn't replace client-server communication—they serve different purposes and often work together:
Client-Server excels at:
PubSub excels at:
A complete OPC UA implementation might use client-server for control and configuration while using PubSub for telemetry streaming to analytics platforms.
OPC UA PubSub extends OPC UA with publish-subscribe communication patterns essential for Industrial IoT scalability. By decoupling publishers from subscribers through message-oriented middleware, OPC UA PubSub enables one-to-many communication with minimal resource consumption.
The specification supports both brokerless architectures using UDP multicast for local real-time control and broker-based architectures using MQTT or AMQP for cloud integration and massive scalability. Publishers structure data into datasets with metadata that enables subscribers to interpret information correctly regardless of their OPC UA knowledge.
Practical implementations demonstrate how OPC UA servers can publish data directly to MQTT brokers, enabling cloud analytics platforms, mobile applications, and other non-OPC UA systems to consume industrial data streams. This bridges the gap between traditional industrial automation and modern IoT architectures, creating unified systems that span from factory floor sensors to cloud-based intelligence.