MQTT in Azure Web PubSub service (Preview)

Note

MQTT support in Azure Web PubSub is in preview stage.

Overview

MQTT is a lightweight pub/sub messaging protocol designed for devices with constrained resources. Azure Web PubSub service now natively supports MQTT over WebSocket transport, enabling cross-communication between MQTT web clients and other Web PubSub clients

This new capability addresses two key use cases:

  1. Real-time applications with mixed protocols: You can allow clients using different protocols to exchange data in real-time through Azure Web PubSub service.

  2. Support for more programming languages: You can use any MQTT library to connect with the service, making it possible to integrate with applications written in languages like C++, beyond the available SDKs in C#, JavaScript, Python, and Java.

It’s important to note that this MQTT support is a lightweight adaptation of the MQTT protocol and extends only to the features already supported by Azure Web PubSub. Some MQTT features that aren't supported include:

  • Wildcard subscriptions
  • Retained messages
  • Shared subscriptions
  • Topic alias

For a comprehensive list of what MQTT features are supported, read this documentation article.

For a more comprehensive MQTT broker solution on Azure, we recommend exploring Azure Event Grid.

Real-time data exchange patterns enabled by the MQTT support

  • Pub/Sub among MQTT web clients and Web PubSub native clients
  • Broadcast messages to MQTT web clients
  • Receive notifications for lifetime events of MQTT web client

How MQTT is adapted into Web PubSub's system

Note

This section assumes you have basic knowledge about MQTT protocols and Azure Web PubSub.

Azure Web PubSub service now recognizes MQTT messages and translates them to its native protocols. The following table shows similar or equivalent term mappings between MQTT and Web PubSub. It helps you understand how we adapt MQTT concepts into those found in Web PubSub. It's essential if you want to use the data-plane REST API or client event handlers to interact with MQTT web clients.

MQTT terms Corresponding Web PubSub terms Relationship
Server/MQTT Broker Web PubSub Service Web PubSub service work as MQTT brokers to serve MQTT connections. Please note that we usually use the term server to refer to the upstream server instead of the MQTT brokers in the documents.
Session Connection Connection in Web PubSub is a logical concept that represents a stateful relationship between the client and service, and one Connection is corresponding to one Session. Usually these two words are interchangeable.
Subscribe To A Topic Join A Group These two actions have the same effect: the client will receive messages from that topic or group. Topic name is the group name.
Publish Message To A Topic Send Message To A Group These two actions have the same effect: the client who subscribes to that topic or belong to that group will receive the message
Client ID Connection ID Connection ID identifies a Connection to Web PubSub. We use the Client ID as the Connection ID of MQTT connections in Web PubSub.

Next step