# How to use component 3rdParty paho.mqtt.c

**URL:** <https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612>\
**Category:** Legato Application Framework\
**Created:** [February 16, 2021, 1:59pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612 "2021-02-16T13:59:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 16, 2021, 1:59pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/1 "2021-02-16T13:59:04Z")

</div>

How to reuse the third party component available in the directory?  
`wp77-legato / 3rdParty / paho.mqtt.c /`

Is it possible to include it as a dependency in my project to use the MQTTClient?  
Could anyone provide an example?

---

<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:** [February 16, 2021, 2:41pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/2 "2021-02-16T14:41:41Z")

</div>

This platformServices application already used this paho.mqtt.c:

> <https://github.com/legatoproject/legato-af/blob/master/apps/platformServices/mqttClient/mqttClientService/Component.cdef>

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 16, 2021, 3:02pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/3 "2021-02-16T15:02:11Z")

</div>

Thanks in advance!

However, applying this configuration in the “.cdef” file of my project, causes the following error during compilation:

```
[1/1] Regenerating build script
[60/476] Running external build step
make: Nada a ser feito para 'tinyhttp'.
[66/476] Running external build step
FAILED: paho_mqtt_cExternalBuild_line0

```

[log\_error\_compile.txt](https://forum.legato.io/uploads/short-url/Obx6j1kBmiE8PJtt8ePfI29a0q.txt) (104.2 KB)

Follows Configuration that generated the problem:

```
sources:
{
    fx30sSerialMqttComponent.c
}

requires:
{
    component:
    {
        ${LEGATO_ROOT}/components/3rdParty/paho.mqtt.c
        ${LEGATO_ROOT}/components/3rdParty/openssl
    }
    lib:
    {
        libpaho-mqtt3cs.so
    }
}

cflags:
{
    -std=c99
    -I${LEGATO_ROOT}/3rdParty/paho.mqtt.c/src
}

ldflags:
{
    -L${LEGATO_BUILD}/3rdParty/paho.mqtt.c
}

```

---

<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:** [February 16, 2021, 3:10pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/4 "2021-02-16T15:10:49Z")

</div>

I don’t see problem to import the same platform service mqttclient to Developer studio and compile it with WP76 FW R13 package:

> **[legato-af/apps/platformServices/mqttClient at master · legatoproject/legato-af](https://github.com/legatoproject/legato-af/tree/master/apps/platformServices/mqttClient)**
>
> master/apps/platformServices/mqttClient

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 16, 2021, 3:23pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/5 "2021-02-16T15:23:01Z")

</div>

I’m using VSCode with a legato plugin, how do I import this service to the platform?

---

<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:** [February 16, 2021, 3:30pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/6 "2021-02-16T15:30:29Z")

</div>

Just copy and paste to your app folder.

Here is my application in workspace.

[mqttClient\_platformservice.7z](https://forum.legato.io/uploads/short-url/7d0iZ1EzeYo8qn7y98ARRLAZ9f.7z) (2.4 MB)

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 16, 2021, 5:04pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/7 "2021-02-16T17:04:31Z")

</div>

Even when copying the folder to the workspace, an error occurs when compiling using mqttClient.adef

```
> Executing task: mkapp ${LEGATO_DEF_FILE} -s components -t ${LEGATO_TARGET} -w ${LEGATO_OBJECT_DIR} -o ${LEGATO_OUTPUT_DIR} && update ${LEGATO_UPDATE_FILE} <

[1/15] Running external build step
FAILED: paho_mqtt_cExternalBuild_line0 
cd /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/_build_mqttClient/wp77xx/component/6bb567e2815475ed6c9fec542269648d && export CFLAGS="--sysroot=/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi -I /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/_build_mqttClient/wp77xx -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/interfaces -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/framework/include -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/framework/include -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s" CXXFLAGS="--sysroot=/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi -I /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/_build_mqttClient/wp77xx -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/interfaces -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/framework/include -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/framework/include -I/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s" LDFLAGS="--sysroot=/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi " CPPFLAGS="--sysroot=/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi " PATH="${LEGATO_ROOT}/bin:/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi:/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/x86_64-pokysdk-linux/usr/bin:/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/x86_64-pokysdk-linux/bin:/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-toolchain/sysroots/x86_64-pokysdk-linux/sbin:$PATH" && mkdir -p /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c/build && make -C /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/3rdParty/paho.mqtt.c blddir=/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c blddir_work=/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c/build
make: Entrando no diretório '/home/cesar/.leaf/wp77-legato_19.11.5-202102090345/3rdParty/paho.mqtt.c'
mkdir -p /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c/samples
mkdir -p /home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c/test
echo OSTYPE is Linux
OSTYPE is Linux
make: *** Sem regra para processar o alvo 'src/VersionInfo.h.in', necessário por '/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c/build/VersionInfo.h'. Pare.
make: Saindo do diretório '/home/cesar/.leaf/wp77-legato_19.11.5-202102090345/3rdParty/paho.mqtt.c'
[5/15] Compiling C source
ninja: build stopped: subcommand failed.
The terminal process "/bin/bash '-c', 'mkapp ${LEGATO_DEF_FILE} -s components -t ${LEGATO_TARGET} -w ${LEGATO_OBJECT_DIR} -o ${LEGATO_OUTPUT_DIR} && update ${LEGATO_UPDATE_FILE}'" failed to launch (exit code: 1).

```

After adding the VersionInfo.h.in file the error changed to:

```
make: *** Sem regra para processar o alvo 'src/samples/MQTTClient_publish.c', necessário por '/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/leaf-data/SWI-WP77/wp77-legato/build/wp77xx/3rdParty/paho.mqtt.c/samples/MQTTClient_publish'. Pare.
make: Saindo do diretório '/home/cesar/.leaf/wp77-legato_19.11.5-202102090345/3rdParty/paho.mqtt.c'

```

---

<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:** [February 17, 2021, 2:48am UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/8 "2021-02-17T02:48:18Z")

</div>

This time I compiled in VSCode with swi-fx30-catm\_2.0.0 package, no problem is found.

1. leaf shell
2. cd apps/Demo/mqttClient\_platformservice/Target\_Legato\_Debug
3. make

You can use my application.  
[mqttClient\_platformservice.7z](https://forum.legato.io/uploads/short-url/ugoMxhqbMKtTCkc09PuvlxDUChm.7z) (2.5 MB)

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 17, 2021, 12:46pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/9 "2021-02-17T12:46:38Z")

</div>

Thanks, your app worked correctly.

Is there any documentation or example for using this mqttClientService api?

I’m trying to create the connection but something is missing from the build:

```
mqtt_Session sessionRef;
mqtt_CreateSession(server, clientId, sessionRef);
mqtt_SetConnectOptions(sessionRef, 20, 0, user, pwd, strlen(pwd), 300, 5 );

```

Compile Error:

```
/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/components/fx30sSerialMqttComponent/fx30sSerialMqttComponent.c:72:6: error: unknown type name ‘mqtt_Session’
      mqtt_Session* sessionRef;
      ^ ~~~~~~~~~~~
/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/components/fx30sSerialMqttComponent/fx30sSerialMqttComponent.c:73:6: error: implicit declaration of function ‘mqtt_CreateSession’; did you mean ‘le_msg_CreateSession’? [-Werror=implicit-function-declaration]
      mqtt_CreateSession(server, clientId, sessionRef);
      ^ ~~~~~~~~~~~~~~~~~
      le_msg_CreateSession
/home/cesar/dev/smartmind/modem-fx30s/conversor-mqtt/vscode/fx30s/components/fx30sSerialMqttComponent/fx30sSerialMqttComponent.c:74:6: error: implicit declaration of function ‘mqtt_SetConnectOptions’ [-Werror=implicit-function-declaration]
      mqtt_SetConnectOptions(sessionRef, 20, 0, user, pwd, strlen(pwd), 300, 5 );
      ^ ~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

```

---

<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:** [February 17, 2021, 1:14pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/10 "2021-02-17T13:14:26Z")

</div>

you need to modify the Makefile, in the line calling mkapp, you need to add some compilation flag like “-C -Wno-error=implicit-function-declaration”

BTW, you can see this example on mqtt application:

> **[legato-af/apps/sample/mqtt at master · legatoproject/legato-af](https://github.com/legatoproject/legato-af/tree/master/apps/sample/mqtt)**
>
> master/apps/sample/mqtt

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 17, 2021, 1:24pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/11 "2021-02-17T13:24:46Z")

</div>

But the session reference, how is it?

```
unknown type name 'mqtt_Session'

```

---

<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:** [February 17, 2021, 1:26pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/12 "2021-02-17T13:26:05Z")

</div>

did you try the sample code:

> **[legato-af/apps/sample/mqtt at master · legatoproject/legato-af](https://github.com/legatoproject/legato-af/tree/master/apps/sample/mqtt)**
>
> master/apps/sample/mqtt

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 17, 2021, 7:56pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/13 "2021-02-17T19:56:37Z")

</div>

I followed the example of the link, but I’m having problems with bindings

`Client interface 'demo.demoComponentExe.demoComponent.mqtt' is not bound to anything.`

Follows configuration:

// demo.adef

```
executables:
{
    demoComponentExe = ( demoComponent )
}

processes:
{
    run:
    {
        ( demoComponentExe )
    }
}

bindings:
{
    demo.demoComponentExe.demoComponent.mqtt -> mqttClient.mqtt
}

```

// Componet.cdef

```
sources:
{
    demoComponent.c
}
requires:
{
    api:
    {
        ${LEGATO_ROOT}/apps/platformServices/mqttClient/mqtt.api
    }
}

```

---

<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:** [February 17, 2021, 11:58pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/14 "2021-02-17T23:58:41Z")

</div>

So you can compile the application now?

Is that the mqttClient\_platformservice is not actually running?

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 18, 2021, 12:58pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/15 "2021-02-18T12:58:28Z")

</div>

The problem is that the mqttClient was running after the demo application

```
root@fx30s:~# app info mqttClient
mqttClient
  status: running
  running processes:
    mqttClientService[3264] (3264)
  app.name: mqttClient
  app.md5: 4dffc9e3b28f80bf44a9284256b19cbe
  app.version: 
  legato.version: 19.11.5

```

Now I can compile and run the demo app

```
root@fx30s:~# app info demo
demo
  status: running
  running processes:
    demoComponentExe[5459] (5459)
  app.name: demo
  app.md5: be9d14db5c5edf3a8e6c792fe44b11d3
  app.version: 
  legato.version: 19.11.5

```

However, after including mqttclient\_Service, my demo application is not running COMPONENT\_INIT.

```
COMPONENT_INIT
{
    // Write in the log that this component has started.
    do {
        LE_INFO("Component demoComponent started.");
        sleep(1);
	} while (1);
}

```

Note that my test log does not come out on the console

```
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c app_Start() 3471 | Starting app 'demo'
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/dev/log' to '/legato/systems/current/appsWriteable/demo/dev/log': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/dev/null' to '/legato/systems/current/appsWriteable/demo/dev/null': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/dev/zero' to '/legato/systems/current/appsWriteable/demo/dev/zero': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/dev/urandom' to '/legato/systems/current/appsWriteable/demo/dev/urandom': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/legato/systems/current/lib/liblegato.so' to '/legato/systems/current/appsWriteable/demo/lib/liblegato.so': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/ld-linux.so.3' to '/legato/systems/current/appsWriteable/demo/lib/ld-linux.so.3': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/libc.so.6' to '/legato/systems/current/appsWriteable/demo/lib/libc.so.6': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/libpthread.so.0' to '/legato/systems/current/appsWriteable/demo/lib/libpthread.so.0': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/librt.so.1' to '/legato/systems/current/appsWriteable/demo/lib/librt.so.1': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/libdl.so.2' to '/legato/systems/current/appsWriteable/demo/lib/libdl.so.2': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/libgcc_s.so.1' to '/legato/systems/current/appsWriteable/demo/lib/libgcc_s.so.1': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/lib/libm.so.6' to '/legato/systems/current/appsWriteable/demo/lib/libm.so.6': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/usr/lib/libstdc++.so.6' to '/legato/systems/current/appsWriteable/demo/lib/libstdc++.so.6': Already exists
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/legato/systems/current/apps/demo/read-only/lib/libComponent_demoComponent.so' to '/legato/systems/current/appsWriteable/demo/lib/lib
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link '/legato/systems/current/apps/demo/read-only/bin/demoComponentExe' to '/legato/systems/current/appsWriteable/demo/bin/demoComponentExe
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateTmpFs() 1788 | Mounted tmpfs at /legato/systems/current/appsWriteable/demo/tmp.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2154 | Created file link '/tmp/legato/serviceDirectoryServer' to '/legato/systems/current/appsWriteable/demo/tmp/legato/serviceDirectoryServer'.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | app.c CreateFileLink() 2154 | Created file link '/tmp/legato/serviceDirectoryClient' to '/legato/systems/current/appsWriteable/demo/tmp/legato/serviceDirectoryClient'.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | resourceLimits.c GetCfgResourceLimit() 207 | Configured resource limit maxStackBytes is not available. Using the default value 0.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | proc.c proc_Start() 1403 | Starting process 'demoComponentExe' with pid 5459
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[899]/supervisor T=main | supervisor.c SigChildHandler() 899 | Reaping unconfigured child process 5457.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | proc.c proc_Start() 1363 | Execing 'demoComponentExe'
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxCoreDumpFileBytes to value 102400.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxFileBytes to value 102400.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxLockedMemoryBytes to value 8192.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxFileDescriptors to value 256.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxMQueueBytes to value 512.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxThreads to value 20.
Feb 18 09:35:38 fx30s user.info Legato: INFO | supervisor[5459]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxQueuedSignals to value 100.

```

What to do to make my implementation run on COMPONENT\_INIT ?

---

<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:** [February 18, 2021, 1:23pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/16 "2021-02-18T13:23:48Z")

</div>

Seems you don’t really try the sample code!!!  
I don’t see problem with it.  
[mqtt.rar](https://forum.legato.io/uploads/short-url/nKZUcKJ1upQGZWFPvjFe3jQNL1D.rar) (5.0 KB)

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 18, 2021, 6:16pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/17 "2021-02-18T18:16:38Z")

</div>

Thanks @jyijyi !

Missing free remote access to the test mqtt broker

```
listener 1883 0.0.0.0
allow_anonymous true

```

Now it’s working properly!

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 19, 2021, 1:49pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/19 "2021-02-19T13:49:49Z")

</div>

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.info Legato: INFO | mqttClientService[4328] | Version: 1.3.0
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | Build level: ter 16 fev 2021 15:51:51 -03
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | OpenSSL version: OpenSSL 1.0.2p 14 Aug 2018
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | OpenSSL flags: compiler: arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security 
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | bug-types -Wall -Wa,--noexecstack
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | OpenSSL build timestamp: built on: reproducible build, date unspecified
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | OpenSSL platform: platform: linux-armv4
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | OpenSSL directory: OPENSSLDIR: "/usr/lib/ssl"
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | =========================================================
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | 20210219 134531.917 getaddrinfo failed for addr mqtt.dioty.co with rc -2
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | 20210219 134531.917 mqtt.dioty.co is not a valid IP address
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | 20210219 134531.917 getaddrinfo failed for addr mqtt.dioty.co with rc -2
Feb 19 10:45:31 fx30s user.info Legato: INFO | mqttClientService[4328] | 20210219 134531.917 mqtt.dioty.co is not a valid IP address
Feb 19 13:45:32 fx30s user.warn Legato: -WRN- | mqttClientService[4328]/mqttClientServiceComponent T=main | mqttClientServiceComponent.c mqtt_Connect() 361 | Socket error
Feb 19 13:45:32 fx30s user.err Legato: =ERR= | testPublisher[4523]/testPublisher T=main | testPublisher.c _testPublisher_COMPONENT_INIT() 138 | Connection failed! error -6

```

to access the mqtt broker on the internet should I do any additional configuration?

---

<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:** [February 19, 2021, 2:53pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/20 "2021-02-19T14:53:17Z")

</div>

Can you try using real ip address in the application?

---

<div class="post-metadata">

**Author:** ![anderson](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anderson](https://forum.legato.io/u/anderson)\
**Post date:** [February 19, 2021, 2:59pm UTC](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612/21 "2021-02-19T14:59:39Z")

</div>

using the real ip I got the error return -6

```
Feb 19 14:56:41 fx30s user.info Legato: INFO | testPublisher[4655]/testPublisher T=main | testPublisher.c _testPublisher_COMPONENT_INIT() 111 | mqttBrokerURI tcp://104.198.201.218:1883
Feb 19 14:56:41 fx30s user.info Legato: INFO | testPublisher[4655]/testPublisher T=main | testPublisher.c _testPublisher_COMPONENT_INIT() 112 | clientId 354723090107292-pub
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | =========================================================
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | Trace Output
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | Product name: Eclipse Paho Synchronous MQTT C Client Library
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | Version: 1.3.0
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | Build level: ter 16 fev 2021 15:51:51 -03
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | OpenSSL version: OpenSSL 1.0.2p 14 Aug 2018
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | OpenSSL flags: compiler: arm-poky-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security 
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | bug-types -Wall -Wa,--noexecstack
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | OpenSSL build timestamp: built on: reproducible build, date unspecified
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | OpenSSL platform: platform: linux-armv4
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | OpenSSL directory: OPENSSLDIR: "/usr/lib/ssl"
Feb 19 11:56:41 fx30s user.info Legato: INFO | mqttClientService[1074] | =========================================================
Feb 19 11:56:41 fx30s user.err kernel: [1243.191660] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:42 fx30s user.err kernel: [1244.192160] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:43 fx30s user.err kernel: [1245.541988] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:44 fx30s user.err kernel: [1246.192173] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:45 fx30s user.err kernel: [1247.576582] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:49 fx30s user.err kernel: [1251.121999] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:50 fx30s user.err kernel: [1252.423537] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:55 fx30s user.err kernel: [1257.025079] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:56 fx30s user.err kernel: [1258.220732] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:56:58 fx30s user.err kernel: [1260.763566] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:57:12 fx30s user.err kernel: [1274.281403] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:57:14 fx30s user.err kernel: [1275.823547] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 11:57:44 fx30s user.err kernel: [1306.361519] disconnect_to_bam: shutdown completion time was: 5000 msec
Feb 19 14:57:46 fx30s user.warn Legato: -WRN- | mqttClientService[1074]/mqttClientServiceComponent T=main | mqttClientServiceComponent.c mqtt_Connect() 361 | Socket error
Feb 19 14:57:46 fx30s user.err Legato: =ERR= | testPublisher[4655]/testPublisher T=main | testPublisher.c _testPublisher_COMPONENT_INIT() 138 | Connection failed! error -6

```

[Next page](https://forum.legato.io/t/how-to-use-component-3rdparty-paho-mqtt-c/5612.md?page=2)
