MQTTnet is a comprehensive MQTT library for .NET that supports both client and broker roles in a single codebase. It provides a full-featured broker implementation capable of hosting a server with access control, message interception, session persistence, and support for mixed MQTT protocol versions. The client side offers robust publish-subscribe communication with automatic reconnection that preserves quality-of-service guarantees, ensuring reliable message delivery across network interruptions.
The library distinguishes itself with a plugin-based authentication pipeline for validating client credentials and a message interception system that allows custom processing of every published message. It includes TLS encryption for protecting data in transit, protocol-version negotiation to adapt to different client capabilities, and a QoS-aware retransmission engine that guarantees exactly-once and at-least-once delivery. The broker supports broker-side message publishing, client disconnection, and clean session management.
MQTTnet covers the full MQTT capability surface including connection establishment, topic subscription, message publishing, incoming message handling with detailed acknowledgments, and a unified communication framework that wraps multiple transport protocols with automatic reconnection and message queuing. The library's session-state persistence stores client subscriptions and missed messages across restarts, enabling durable messaging patterns. Its asynchronous TCP socket model handles thousands of concurrent connections without blocking threads, making it suitable for high-throughput scenarios. The documentation and install surface are available through the project's GitHub repository and NuGet packages.