I'd like to implement an MQTT client functionality in C++ (it needs to be thread-safe, and be able to subscribe to topics and also publish, but no broker functionality is needed).
I was considering Paho MQTT by Eclipse. Here is their download page.
I find there that they don't have MQTT5.0 support.
On their github however: there is C++ wrapper which at version 1.1 states MQTTv5.0 support.
Then I have found this question: Mosquitto vs eclipse paho client library, where the conclusion was:
to use libmosquitto with libmosquittopp wrapper
I checked libmosquittopp.h: all functions are marked as deprecated, so I don't think it can be the right way as of now.
Why is libmosquittopp deprecated? Because
The wrapper came about by an external request and at the time it was created there were no other C++ solutions for MQTT. This has changed in the past years and this wrapper provides no benefit over true C++ libraries or using the pure C libmosquitto.
So, is Paho now considered the right direction for using MQTT within C++?
Or I shall just use the pure C library by Mosquitto?
Or, anything else (except writing it from 0)?
The Paho C++ library does support MQTT v5, and is thread safe. You can publish and subscribe from multiple threads with a single client connection.
Some of the Eclipse web pages need to be updated with the latest features. The GitHub repos tend to have the latest information.
The Paho C++ lib just wraps the Paho C library, but provides an asynchronous, futures-style API, and provides memory management via shared pointers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With