Announcing MQTT Support in Azure Web PubSub Service (public preview)
We’re excited to announce the long-requested release of MQTT support in Azure Web PubSub service, now available in preview! This added capability allows developers to leverage the lightweight and widely used MQTT protocol for messaging, making it easier to connect and communicate with devices that have constrained resources.
What is MQTT?
MQTT (Message Queuing Telemetry Transport) is a lightweight, pub/sub messaging protocol designed specifically for low-bandwidth, high-latency, or unreliable networks. It’s an ideal choice for IoT (Internet of Things) devices and other scenarios where resources are limited. Development teams even build chat apps using MQTT protocol.
Now, with Azure Web PubSub’s support for MQTT, you can connect clients running on WebSocket protocol or MQTT (over WebSocket) without worrying about scalability. Better yet, these clients can cross-communicate with each other despite the different protocols used, making it an ideal architectural solution if an application has mixed clients.
Key features of MQTT in Azure Web PubSub
Compliant support for MQTT protocols:
Azure Web PubSub supports MQTT 3.1.1 and 5.0 protocols, allowing any MQTT library with WebSocket transport to connect directly to Azure Web PubSub service. This makes it easy to integrate MQTT with existing systems, regardless of the programming language or platform.
Cross-protocol communication:
With cross-protocol communication, MQTT clients can interact with other clients using different Web PubSub protocols. This feature expands the possibilities for integrating diverse systems and devices within a single communication hub. Find more details here
Seamless adoption for existing Web PubSub customers
Current customers of Azure Web PubSub can adopt MQTT with minimal modifications. The Web PubSub REST API is already equipped to handle MQTT connections, ensuring a smooth transition.
Client-to-server request/response model
In addition to the traditional client-to-client pub/sub model, Azure Web PubSub supports a client-to-server request/response model. Specific MQTT application messages can be converted into HTTP requests, which are sent to registered webhooks. The responses are then delivered back to the MQTT clients as application messages. For more details, see MQTT custom event handler protocol.
Supported features
Azure Web PubSub fully supports MQTT 3.1.1 and 5.0. Features included:
Quality of Service (QoS): All levels, including “at most once”, “at least once”, and “exactly once” .
Message order guarantee
Persistent Sessions: Sessions are preserved for up to 30 seconds during connection interruptions.
Last Will & Testament: Ensures that a final message is sent if a client disconnects unexpectedly.
Client Certificate Authentication
For MQTT 5.0, additional features include:
Message Expiry Interval and Session Expiry Interval
Subscription Identifier
Assigned Client ID
Flow Control
Server-Sent Disconnect
Unsupported features in this preview
Wildcard subscriptions
Retained messages
Shared subscriptions
Authentication and authorization
Azure Web PubSub offers two workflows for authenticating and authorizing MQTT clients:
JWT-Based Authentication: The MQTT client obtains a JWT token and includes it in the WebSocket request. The Web PubSub service then validates the token.
Upstream Server Authentication: After establishing a WebSocket connection, the MQTT client sends a CONNECT packet. The Web PubSub service calls an API on the upstream server to authenticate the client using the username, password, and TLS certificate.
These workflows can be used independently or in combination, providing flexibility in securing your MQTT communications.
Client lifetime event notifications
Azure Web PubSub allows you to register event handlers to receive notifications when an MQTT client session starts or ends, providing greater visibility into your system’s activity.
REST API support
The Azure Web PubSub REST API now supports operations specifically for MQTT clients, including:
Publishing messages to topics, connections, users, or all connections.
Managing client permissions and subscriptions.
Get started today!
We’re thrilled to bring MQTT support to Azure Web PubSub, and we can’t wait to see how you’ll use this feature in your projects. To have a try quickly, check out PubSub among MQTT clients – Azure Web PubSub .
Explore these new capabilities and elevate your applications with the power of MQTT in Azure Web PubSub!
Microsoft Tech Community – Latest Blogs –Read More