OPC UA and MQTT: IIoT Communication Protocols

When it comes to IoT protocols, there are two main communication protocols that are commonly used and sometimes in parallel to each other. They are MQTT and OPC UA.  We’ll take a look at both protocols, their similarities, differences, and advantages. 

MQTT

MQTT (Message Queue Telemetry Transport) is a lightweight messaging protocol that uses the publish-subscribe method to produce and consume messages. In MQTT, the publisher sends out messages and subscribers receive these messages without necessarily knowing the producer of the message. MQTT is designed for low-resource devices, in low-bandwidth networks and high latency. We go into more detail in our MQTT guide which you can find here. 

In MQTT, we have the broker and the clients. The MQTT broker is an intermediary that allows clients to communicate by filtering messages published by MQTT clients and sending them out to subscribers.  Eclipse Mosquitto, from the Eclipse Foundation, is an MQTT broker. MQTT clients on the other hand are devices that publish messages and subscribe to topics.   

To find out more about MQTT, its specifications, use cases, and software, visit Mqtt.org.

OPC UA

OPC UA Architecture
OPC UA architecture

OPC UA (Open Platform Communications Unified Architecture) was released in 2008 by the OPC foundation. You can discover more information about OPC UA on their website. OPC UA is designed for information exchange in industrial environments.  It is a client/server-based architecture and it enables machines to machine communication as well as machine to systems communication.

OPC UA can be used in closed networks or over the internet. Security is provided through user control, encryption, and authentication of users, clients, and servers.

Similarities

Where both protocols are similar:

  • Security: They both have an in-built security layer and both allow TLS encrypted access, using a password or certificate, or unencrypted.
  • In both, hierarchical structures can be created relatively easily to structure the data storage.

Advantages of MQTT

  • It is lightweight and works in resource-constrained environments and low bandwidth devices thereby saving resources.
  • MQTT allows for scalability as an unlimited number of clients can publish and consume messages at the same time.
  • MQTT has clear handshakes, rules through Last Will Messages and Retained Message to regulate disconnections.
  • MQTT is easier to implement than OPC UA. It requires less time, effort, and money.
  • Access to the cloud: MQTTS or MQTT over webSockets (with/without TLS) is generally easier to pull out over firewalls than OPC UA, since at least MQTT over websockets is HTTP-based.
  • It can be operated as a high-availability cluster. With (central) OPC UA it maybe theoretically possible and if it is, then it is quite complicated.
  • MQTT serves as an event-based protocol. That is, if there are changes to a status or a variable, the client is informed. But he doesn’t have to pull constantly.
  • In MQTT, the number of connections grows linearly with the number of clients, but with OPC UA it depends on whether each machine has its own OPC UA (then in extreme cases the number of connections grows quadratically) or whether there is a central OPC UA server and on the machines clients only (then also linear growth in the number of connections).

Advantages of OPC UA

  • Many machines now have an OPC UA server onboard, overall, the OPC UA standard is (still) more widespread in the industrial sector than MQTT.
  • You can use discovery queries to read out directly which structures are available on the OPC UA server. MQTT brokers allow very flexible structuring and only communicate something to their clients if there is a (first) message on the topic.
  • Unified semantics: With MQTT you can completely define the topic trees yourself. With OPC UA, depending on the industry, there may be so-called “Companion Specifications” which then define the structure on the server for an industry sector.
  • Using OPC UA over MQTT gives you END-TO-END encryption. This means encryption is established between the OPC UA publisher and OPC UA subscriber so data remains encrypted regardless of how many hops there are between the publisher and subscriber. This is in contrast to MQTT-only security which relies on each broker along the route not being compromised.

With all these taken into consideration, it is important to note that MQTT and OPC UA can work harmoniously well together.  Want to find out how you can use MQTT and OPC UA in your specific projects? Contact us and talk to our experts!

Contact us!

Talk with our experts:

Stefan Loelkes
CRO
+ 49-1590-48 60 270
stefan.loelkes@cedalo.com

 

To learn more about Stream Processing for Ec;ipse Mosquitto, click here. To learn more about High Availability for Eclipse Mosquitto click here.

Image credits

OPC UA architecture illustration is from the OPC UA foundation website.