Skip to content
Christian edited this page Aug 14, 2022 · 14 revisions

How does MQTT work and what are the best practices?

This project does not cover explanation of MQTT as a such. This library only has barely comments so that knowledge about the protocol is required before getting started with this library.

This is by design and will not change. The recommended source for tutorials etc. is https://www.hivemq.com/blog/how-to-get-started-with-mqtt.

More detailed information is available in the officials RFCs of the MQTT protocol (v3.1.1, v5.0.0).

How to use this library?

Code samples for using this library are available in the repository located in the Samples directory. Most of these samples can also be executed. This requires cloning this repository, compiling and running the console application MQTTnet.Samples.csproj.

How to debug the protocol?

For MQTT protocol debugging and analytics the MQTT Client MQTTnetApp should be used to inspect messages, payloads etc. It is recommended to test connections and features using this client before opening tickets.

The code of this library can be debugged via attaching the debugger to certain Unit Tests.

FAQ

I have performance issues.

In order to get maximum performance it is very important to use a RELEASE build of the affected application. Also the MQTTnet log should not be activated (off by default).

My connection remains "Connected" (IsConnected=true) but the socket is already disconnected or the network connection is broken/disabled.

This is by design. See post https://github.com/xamarin/xamarin-android/issues/1347#issuecomment-369729481. So switch over to at least QoS 1. Then the client can use a timeout and disconnect when no response is received.

I have troubles connecting when using TLS.

Please see https://docs.microsoft.com/en-us/dotnet/core/compatibility/cryptography/5.0/default-cipher-suites-for-tls-on-linux.