Bridging Decentralized IoT Messaging: Integrating MQTT with libp2p PubSub in Cyberfly

3 min readApr 22, 2024



In the ever-expanding realm of IoT (Internet of Things), messaging protocols form the backbone of communication between devices, sensors, and systems. MQTT (Message Queuing Telemetry Transport) has emerged as a lightweight and efficient protocol, well-suited for IoT applications. However, as the demand for decentralized IoT platforms grows, integrating MQTT with decentralized networking protocols like libp2p becomes imperative. In this article, we delve into the integration of MQTT with libp2p’s PubSub capabilities within the Cyberfly decentralized IoT platform, exploring its significance and advantages.

Understanding MQTT, libp2p, and PubSub:

MQTT is a widely adopted publish-subscribe messaging protocol, designed for resource-constrained devices and unreliable networks typical in IoT environments. Its client-server architecture, where clients publish messages to a central broker and other clients subscribe to topics, has made it a go-to choice for IoT applications due to its lightweight nature and support for Quality of Service levels.

libp2p, on the other hand, provides a modular network stack tailored for peer-to-peer communication, simplifying the development of decentralized applications. With support for various transport protocols like TCP/IP, UDP, and WebRTC, libp2p offers versatility and resilience in diverse networking scenarios. Moreover, libp2p features a PubSub (Publish-Subscribe) subsystem, enabling decentralized communication through topics similar to MQTT.

Integration of MQTT with libp2p PubSub in Cyberfly:

Cyberfly is a decentralized IoT platform built atop kadena and libp2p, offering a suite of communication tools tailored for IoT deployments. By integrating MQTT with libp2p’s PubSub subsystem, Cyberfly combines the simplicity and efficiency of MQTT messaging with the decentralized and peer-to-peer capabilities of libp2p.

The integration involves adapting MQTT to utilize libp2p’s PubSub mechanism for communication, enabling interoperability between MQTT clients and libp2p nodes. This seamless bridging allows MQTT clients to publish and subscribe to topics hosted on the libp2p network, fostering decentralized communication without the need for a central broker.

Benefits of the integration:

  1. Decentralization: Leveraging libp2p’s decentralized networking capabilities, the integration enables MQTT clients to communicate directly with libp2p nodes using PubSub. This decentralized architecture enhances network resilience, minimizes latency, and reduces dependency on centralized infrastructure.
  2. Interoperability: libp2p’s PubSub subsystem is interoperable with MQTT, allowing existing MQTT clients and devices to seamlessly integrate with the Cyberfly platform. This ensures compatibility with existing IoT ecosystems while harnessing the benefits of decentralized communication.
  3. Scalability: With MQTT over libp2p PubSub, the Cyberfly platform can scale effortlessly as new IoT devices join the network. Devices dynamically discover and connect to each other, facilitating seamless communication in large-scale IoT deployments.
  4. Security: libp2p’s built-in support for encryption, authentication, and secure transport protocols enhances the security of MQTT communication within the Cyberfly platform. This ensures that IoT data remains confidential and tamper-proof, mitigating the risk of unauthorized access or data breaches.


The integration of MQTT with libp2p’s PubSub subsystem within the Cyberfly decentralized IoT platform marks a significant advancement in the realm of decentralized IoT messaging. By combining the strengths of MQTT with the interoperability and decentralization of libp2p PubSub, Cyberfly offers a resilient, scalable, and secure platform for IoT deployments. As the IoT landscape continues to evolve, such integrations pave the way for a more decentralized and interconnected future, empowering developers to build innovative IoT solutions with confidence.