# dotnet/mqttnet

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/dotnet-mqttnet).**

4,949 stars · 1,145 forks · C# · mit

## Links

- GitHub: https://github.com/dotnet/MQTTnet
- awesome-repositories: https://awesome-repositories.com/repository/dotnet-mqttnet.md

## Topics

`anycpu` `broker` `communication` `csharp` `iot` `iot-framework` `iot-platform` `mqtt` `mqtt-broker` `mqtt-client` `mqtt-protocol` `mqtt-server` `net` `netcore` `netframework` `nuget` `tcp` `tls` `uwp`

## Description

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.

## Tags

### Networking & Communication

- [Dual-Role Libraries](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/communication-apis/mqtt-message-brokers/dual-role-libraries.md) — A full-featured MQTT library for .NET that supports both client and broker roles with message routing and session management.
- [MQTT Clients](https://awesome-repositories.com/f/networking-communication/communication-platforms-services/messaging-notification-systems/messaging-services/message-broker-infrastructure/publish-subscribe-messaging/mqtt-clients.md) — Sending and receiving messages to an MQTT broker with topic-based publish/subscribe, including automatic reconnection.
- [MQTT Message Brokers](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/communication-apis/mqtt-message-brokers.md) — Starts a server that listens for TCP connections, routes messages, manages client sessions, subscriptions, retained messages, and supports mixed protocol versions. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Server/Server_Simple_Samples.cs))
- [Access Control Modules](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/communication-apis/mqtt-message-brokers/access-control-modules.md) — Enforcing authentication and authorization on MQTT client connections and subscriptions to secure the messaging system.
- [Access-Controlled Brokers](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/communication-apis/mqtt-message-brokers/access-controlled-brokers.md) — Hosts a broker that validates client credentials, enforces subscription rules, and stores retained messages for topic-based publish-subscribe.
- [Non-Blocking TCP Servers](https://awesome-repositories.com/f/networking-communication/asynchronous-socket-libraries/non-blocking-tcp-servers.md) — Manages network I/O with non-blocking sockets to handle thousands of concurrent connections without blocking threads.
- [MQTT Message Handlers](https://awesome-repositories.com/f/networking-communication/communication-platforms-services/communication-platforms/messaging-middleware/message-handling-systems/mqtt-message-handlers.md) — Processes incoming MQTT messages asynchronously via callbacks for custom application logic. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Client/Client_Subscribe_Samples.cs))
- [Publishers](https://awesome-repositories.com/f/networking-communication/communication-platforms-services/messaging-notification-systems/messaging-services/message-broker-infrastructure/publish-subscribe-messaging/mqtt-clients/publishers.md) — Publishes messages to MQTT topics with configurable quality-of-service levels. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Client/Client_Publish_Samples.cs))
- [Topic Subscribers](https://awesome-repositories.com/f/networking-communication/communication-platforms-services/messaging-notification-systems/messaging-services/message-broker-infrastructure/publish-subscribe-messaging/mqtt-clients/topic-subscribers.md) — Subscribes to MQTT topics with support for wildcards and configurable quality-of-service. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Client/Client_Subscribe_Samples.cs))
- [QoS Retransmission Engines](https://awesome-repositories.com/f/networking-communication/message-delivery-guarantees/at-least-once-delivery-guarantees/qos-retransmission-engines.md) — Guarantees exactly-once and at-least-once delivery by tracking packet IDs and retrying with flow control.
- [Broker-Initiated Publications](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/communication-apis/mqtt-message-brokers/broker-initiated-publications.md) — Injects a message directly from the broker into the topic tree, as if a client published it. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Server/Server_Simple_Samples.cs))
- [QoS-Guaranteed Reconnections](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/communication-paradigms/server-to-client-event-emissions/connection-reconnection-policies/automatic-reconnection-logic/qos-guaranteed-reconnections.md) — Reconnects and resends messages with correct QoS to maintain reliable communication with the broker. ([source](https://github.com/dotnet/MQTTnet/blob/master/README.md))
- [QoS-Preserving Reconnections](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/communication-paradigms/server-to-client-event-emissions/connection-reconnection-policies/automatic-reconnection-logic/qos-preserving-reconnections.md) — Automatically reconnects and retransmits messages with correct quality-of-service to maintain reliable communication with the broker.
- [MQTT Message Acknowledgements](https://awesome-repositories.com/f/networking-communication/custom-message-protocols/protocol-acknowledgements/mqtt-message-acknowledgements.md) — Sends detailed acknowledgements with reason codes and user properties for received MQTT messages. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Client/Client_Subscribe_Samples.cs))
- [MQTT Version Detectors](https://awesome-repositories.com/f/networking-communication/http-2-support/protocol-negotiation/version-negotiation/mqtt-version-detectors.md) — Detects the MQTT version in the CONNECT packet and adapts packet parsing and feature support accordingly.
- [Message Interceptors](https://awesome-repositories.com/f/networking-communication/message-delivery-pipelines/message-interceptors.md) — Routes every published message through user-defined interceptors before delivery to subscribers or retained message store.

### Data & Databases

- [MQTT Broker Connections](https://awesome-repositories.com/f/data-databases/redis-clients/cluster-connectivity/message-broker-connectivity/mqtt-broker-connections.md) — Provides TCP connection establishment and protocol version negotiation for MQTT broker communication. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Client/Client_Connection_Samples.cs))
- [Resilient Connections](https://awesome-repositories.com/f/data-databases/redis-clients/cluster-connectivity/message-broker-connectivity/mqtt-broker-connections/resilient-connections.md) — Maintaining reliable MQTT communication with automatic reconnection and message queueing to handle network interruptions.

### Security & Cryptography

- [Messaging Session Persistence](https://awesome-repositories.com/f/security-cryptography/identity-access-management/session-management/stateful-session-persistence/messaging-session-persistence.md) — Stores client subscriptions and missed messages across restarts by serializing session data to a configurable storage backend.
- [Transport Wrappers](https://awesome-repositories.com/f/security-cryptography/security/cryptography-and-secrets/cryptographic-primitives-management/tls-ssl-configurations/transport-wrappers.md) — Wraps raw TCP streams with encryption using configurable certificates and cipher suites for secure communication.
- [MQTT TLS Encryption](https://awesome-repositories.com/f/security-cryptography/ssl-tls-connection-security/mqtt-tls-encryption.md) — Encrypting MQTT traffic over TLS to protect data in transit between clients and the broker. ([source](https://github.com/dotnet/MQTTnet/blob/master/README.md))
- [MQTT Credential Validators](https://awesome-repositories.com/f/security-cryptography/authentication-clients/credential-authentication/handshake-credential-validators/mqtt-credential-validators.md) — Validates client credentials during MQTT connection handshake and rejects unauthorized clients. ([source](https://github.com/dotnet/MQTTnet/blob/master/Samples/Server/Server_Simple_Samples.cs))

### Software Engineering & Architecture

- [Client Credential Validators](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/plugin-module-systems/modular-plugin-architectures/plugin-based-architectures/plugin-based-architectures/authentication-provider-plugins/client-credential-validators.md) — Validates client credentials through configurable handlers that can reject connections with custom reason codes.

### Part of an Awesome List

- [MQTT Communication](https://awesome-repositories.com/f/awesome-lists/media/mqtt-communication.md) — High-performance library for MQTT clients and brokers.
