How to use component 3rdParty paho.mqtt.c

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 (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
}

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

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

Just copy and paste to your app folder.

Here is my application in workspace.

mqttClient_platformservice.7z (2.4 MB)

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'

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 (2.5 MB)

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

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:

But the session reference, how is it?

unknown type name 'mqtt_Session'

did you try the sample code:

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
    }
}

So you can compile the application now?

Is that the mqttClient_platformservice is not actually running?

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 ?

Seems you don’t really try the sample code!!!
I don’t see problem with it.
mqtt.rar (5.0 KB)

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!

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?

Can you try using real ip address in the application?

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

did you try to connect in terminal first?
e.g. using nc command (or even try to ping the IP first in terminal)
This can make sure the module can reach that IP and port.

You might also need to shut down firewall by:

iptables -I INPUT -j ACCEPT

hi @anderson, sorry, where did you write in the code

1883 is mosquitto, right?