paho vs mosquitto for C/C++ client

7,504 views
Skip to first unread message

Vladimir A

unread,
Nov 25, 2016, 5:21:43 AM11/25/16
to MQTT
Hello,

I am going to use MQTT in the C/C++ program which collects data and sends to server. I found that there are two MQTT libraries for C/C++ MQTT client: PAHO and mosquitto. I was looking for difference and didn't find any explanation what library is preferred to use. Both of them are supported by Eclipse. Both support TLS encryption.

Regarding to "git log" mosquitto project has more commits and latest commit for library was in August 2016 (and some later commits for non library part). PAHO has last commit in June 2016. So I can see that both projects are in Active state.

The questions are:

1. What implementation would you recommend to use?

2. What is the difference between those libraries?

3. Why Eclipse is developing two independent MQTT client projects?

kushal bhattacharya

unread,
Nov 25, 2016, 7:53:56 AM11/25/16
to MQTT
from my end mosquitto is  preferrable if u are looking to use c++ version too of the mqtt.The c++ version of paho is not stable . u ca also check my own implemenation of mqtt(in c++) in my github . u can install it via makefile.After using it plesa do give a review about its use cases and pros and cons about it i have tried to cover most of the basic scenarios.

kushal bhattacharya

unread,
Nov 25, 2016, 7:54:53 AM11/25/16
to MQTT

kushal bhattacharya

unread,
Nov 25, 2016, 8:26:21 AM11/25/16
to MQTT
mosquitto can be run locally in your machine and and its c and c++  counterpart is much more stable and efficient

Vladimir A

unread,
Nov 25, 2016, 9:17:56 AM11/25/16
to MQTT
I started to use mosquitto C library couple weeks ago. Minimum functionality I implemented quite fast. But when I started to implement extra functionality I realized that libmosquitto behaves in unexpected way:

1. I didn't find easy way to find out if published message was actually received by broker
2. mosquitto_publish() can return success even if there is no broker connection
3. a lot of error from valgrind memcheck if I use TLS makes me doubt is it's save to use libmosquitto.

That's why I decided to check if mosquitto library is the best available MQTT library. The only alternative is PAHO. But I didn't find any comparison of those two projects.


пятница, 25 ноября 2016 г., 16:26:21 UTC+3 пользователь kushal bhattacharya написал:

kushal bhattacharya

unread,
Nov 25, 2016, 9:27:23 AM11/25/16
to MQTT
the thing is if you are implementing it in c then paho is definitely the best one available in fact i also used it in my mqtt client library

kushal bhattacharya

unread,
Nov 25, 2016, 9:30:26 AM11/25/16
to MQTT
u will get the same memory leak in paho too i didnt check it but when i am using it in my library there are memory leaks in the .so of the paho client so in a way u can't really totally do away with memory leak if u are writing a long project based program but to my opinion minimising memory leak is the challenge

Nicholas O'Leary

unread,
Nov 25, 2016, 9:32:33 AM11/25/16
to mq...@googlegroups.com
Hi kushal,

Both the paho and mosquitto clients are very well tested and used extensively in real production scenarios - so I would not rush to claim any memory leak is in their code...

Nick

On 25 November 2016 at 14:30, kushal bhattacharya <bhattachar...@gmail.com> wrote:
u will get the same memory leak in paho too i didnt check it but when i am using it in my library there are memory leaks in the .so of the paho client so in a way u can't really totally do away with memory leak if u are writing a long project based program but to my opinion minimising memory leak is the challenge

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Vladimir A

unread,
Nov 25, 2016, 9:57:38 AM11/25/16
to MQTT
Hi kushal,

I didn't tell that I found memory leak. All the memcheck problems I saw were related with uninitialized memory usage in libcrypto.so (which I suppose is used for TLS security)

пятница, 25 ноября 2016 г., 17:30:26 UTC+3 пользователь kushal bhattacharya написал:

Paul Fremantle

unread,
Nov 25, 2016, 10:50:53 AM11/25/16
to mq...@googlegroups.com
Vladimir

Are you using QoS0 or QoS1/2?

Paul

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.



--
Paul Fremantle
Doctoral Researcher, University of Portsmouth, School of Computing
Visiting Scientist, Institute of the Architecture of Application Systems, Stuttgart
Visiting Lecturer, Software Engineering Programme, Oxford University
Co-Founder, WSO2
Apache Member and Committer
twitter: pzfreo / skype: paulfremantle / blog: http://pzf.fremantle.org

Vladimir A

unread,
Nov 25, 2016, 1:11:37 PM11/25/16
to MQTT
Paul

I am using QOS=1

пятница, 25 ноября 2016 г., 18:50:53 UTC+3 пользователь Paul Fremantle написал:
Vladimir

Are you using QoS0 or QoS1/2?

Paul
On 25 November 2016 at 15:17, Vladimir A <vl.a...@gmail.com> wrote:
I started to use mosquitto C library couple weeks ago. Minimum functionality I implemented quite fast. But when I started to implement extra functionality I realized that libmosquitto behaves in unexpected way:

1. I didn't find easy way to find out if published message was actually received by broker
2. mosquitto_publish() can return success even if there is no broker connection
3. a lot of error from valgrind memcheck if I use TLS makes me doubt is it's save to use libmosquitto.

That's why I decided to check if mosquitto library is the best available MQTT library. The only alternative is PAHO. But I didn't find any comparison of those two projects.


пятница, 25 ноября 2016 г., 16:26:21 UTC+3 пользователь kushal bhattacharya написал:
mosquitto can be run locally in your machine and and its c and c++  counterpart is much more stable and efficient

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Paul Fremantle

unread,
Nov 25, 2016, 2:47:46 PM11/25/16
to mq...@googlegroups.com
Are you using the message ID mid and setting the publish callback?

Best Paul
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Vladimir A

unread,
Nov 25, 2016, 3:09:18 PM11/25/16
to MQTT
Paul,

I don't use mid and publish callback. Sounds like a good way to check message status. I will try it. Thank you!

пятница, 25 ноября 2016 г., 22:47:46 UTC+3 пользователь Paul Fremantle написал:

kushal bhattacharya

unread,
Nov 25, 2016, 11:53:20 PM11/25/16
to MQTT
hi nick,
when i was running paho client with valgind i found some memcheck issues i think thts minor

Paulo Balbino

unread,
Jan 11, 2017, 3:09:06 PM1/11/17
to MQTT
I am using PAHO C Library, it works well except for TLS/SSL I am not able to use it at all, not able to establish a secure connection. Are you guys able to use TLS/SSL in PAHO?

Vladimir A

unread,
Mar 6, 2017, 6:42:10 AM3/6/17
to MQTT
I use TLS in with PAHO C library. I had problems to establish connection, but I resolved it somehow (don't remember exactly). Probably I just updated libcrypto library.


среда, 11 января 2017 г., 23:09:06 UTC+3 пользователь Paulo Balbino написал:

Pravallika Kolisetty

unread,
Jun 12, 2017, 9:24:19 AM6/12/17
to MQTT
Hi Vladimir,

I am looking for TLS Support in Paho C library. Unfortunately i was not able to find it.  Please share me the lib and source of Paho C TLS support. 

Please share me the link. Thank you in Advance.

Nicholas Humfrey

unread,
Jun 12, 2017, 9:39:31 AM6/12/17
to Pravallika Kolisetty, mq...@googlegroups.com
Hi Pravallika,

You may want to ask on the Paho mailing list - this list is about the
protocol in general, rather than support for specific implementations.

https://dev.eclipse.org/mailman/listinfo/paho-dev

nick.

Axel Schwab

unread,
Aug 13, 2019, 9:11:29 AM8/13/19
to MQTT
@Vladimir A, do you have some answere why there are two libs? :)
Reply all
Reply to author
Forward
0 new messages