# Mqtt broker and client?

**URL:** <https://forum.legato.io/t/mqtt-broker-and-client/5698>\
**Category:** Uncategorized\
**Created:** [April 8, 2021, 8:14am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698 "2021-04-08T08:14:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ga.imparato](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@ga.imparato](https://forum.legato.io/u/ga.imparato)\
**Post date:** [April 8, 2021, 8:14am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/1 "2021-04-08T08:14:18Z")

</div>

Hi all!  
I’m new on this mangOH system and I have to create a MQTT communication.  
I want to use as **broker MOSQUITTO MQTT** and as client I know that there are many options:

1. **Paho library**
2. **MQTT client** folder that is included in mangOH github project:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/0/0fd8f5a231e84132fa0969d169dbd369096b441d.png)

I installed Mosquitto on my ubuntu VM. Can anyone explain to me how to enstabilish a connection between mosquitto mqtt and the client? Which is simpliest to use, paho or mqttClient?

Another question: I activated my device on AirVantage: **can AirVantage be used as broker?**

Is there any tutorial?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 8, 2021, 8:27am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/2 "2021-04-08T08:27:54Z")

</div>

here says local broker is OK:

> [@How to use component 3rdParty paho.mqtt.c](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/19):
>
> it worked very well with the local broker (192.168.2.3) but when trying to use a remote broker on the internet, I get the following error: URL: tcp://mqtt.dioty.co:1883 ========================================================= Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | Trace Output Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | Product name: Eclipse Paho Synchronous MQTT C Client Library Feb 19 10:45:31 fx30s user.inf…

---

<div class="post-metadata">

**Author:** ![ga.imparato](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@ga.imparato](https://forum.legato.io/u/ga.imparato)\
**Post date:** [April 8, 2021, 10:16am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/3 "2021-04-08T10:16:35Z")

</div>

I compiled and updated on the board the .update of your mangOH2-7-19 going into apps/MqttClient.  
I see that the app is running. How can I do to know if all work fine? Are there examples that I can implement with my mangOH green?

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/9/95fff6473dcf0f86b8fa317ed93ee4e7d87501cc.png)

I see this log:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/6/6564a27269c2530830e0d8d80bad833913d6a94f.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 8, 2021, 10:57am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/4 "2021-04-08T10:57:18Z")

</div>

I don’t see any mqttClientService related log…

---

<div class="post-metadata">

**Author:** ![ga.imparato](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@ga.imparato](https://forum.legato.io/u/ga.imparato)\
**Post date:** [April 8, 2021, 12:44pm UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/5 "2021-04-08T12:44:02Z")

</div>

I did the logread whith app start mqttClient…

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 8, 2021, 12:48pm UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/6 "2021-04-08T12:48:37Z")

</div>

maybe it is waiting for the mqttClientService

---

<div class="post-metadata">

**Author:** ![ga.imparato](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@ga.imparato](https://forum.legato.io/u/ga.imparato)\
**Post date:** [April 8, 2021, 12:57pm UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/7 "2021-04-08T12:57:46Z")

</div>

After some minutes…

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/e/e18bf9f3ab0904f3db88aa07ba9374f9d4c2c5dd.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 8, 2021, 1:33pm UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/8 "2021-04-08T13:33:43Z")

</div>

I think you need to debug by yourself…  
You can write some debug message on the component\_init() and see what happens

---

<div class="post-metadata">

**Author:** ![yoaniamerry](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yoaniamerry](https://forum.legato.io/u/yoaniamerry)\
**Post date:** [September 22, 2022, 12:20am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/9 "2022-09-22T00:20:48Z")

</div>

Cannot tell you the exact cause of such a problem, but you might research a guide on how to establish an MQTT client and broker connection works.

---

<div class="post-metadata">

**Author:** ![yoaniamerry](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yoaniamerry](https://forum.legato.io/u/yoaniamerry)\
**Post date:** [September 29, 2022, 4:01am UTC](https://forum.legato.io/t/mqtt-broker-and-client/5698/10 "2022-09-29T04:01:58Z")

</div>

Cannot tell you the exact cause of such a problem, but you might research a guide on how to establish an [MQTT client and broker connection](https://cedalo.com/blog/mqtt-connection-beginners-guide/) works. They have this information on the Cedalo website and forum.  
To begin with, you can read this beginner’s guide on mqtt client and broker connection. It’s written in simple words, explains how the protocol works, and contains a step-by-step guide on establishing a stable and protected connection.  
You can browse their other docs and resources to find more suitable info, especially their forum that mainly deals with MQTT questions. Good luck, man!
