# Getaddrinfo fail inside the mqttClientService

**URL:** <https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818>\
**Category:** Legato Application Framework\
**Created:** [October 23, 2024, 6:33am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818 "2024-10-23T06:33:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elmoo](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@Elmoo](https://forum.legato.io/u/Elmoo)\
**Post date:** [October 23, 2024, 6:33am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/1 "2024-10-23T06:33:26Z")

</div>

Hi,

I’m using legatos built in mqttClientService to connect to an external MQTT broker. However I can only provide ip address to the `mqttClient_CreateSession`.

If I try to use domain for that server, I receive:

```auto
mqttClientService[6672] | 20241023 062637.556 getaddrinfo failed for addr <url> with rc -2
mqttClientService[6672] | 20241023 062637.556 <url> is not a valid IP address

```

If i fetch the IP address on my own with getaddrinfo right before mqttClient\_CreateSession, it returns IP address just fine and I can use it to connect to broker. The problem is that I can’t use ssl that way.

Seems like the mqttClientService cannot use dns or /etc/resolv.conf correctly.  
I’m using legato 19.11.2 and my app is not sandboxed.

Any idea how to make mqttClientService understand domains?

---

<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:** [October 23, 2024, 7:08am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/2 "2024-10-23T07:08:49Z")

</div>

you can see this document:

> **[Using Openssl to implement cryptography](https://mangoh.discourse.group/t/using-openssl-to-implement-cryptography/9107/2)**
>
> you can see this document: SSL in Legato application.docx (464.9 KB)

SSL application should be OK to find the IP address

---

<div class="post-metadata">

**Author:** ![Elmoo](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@Elmoo](https://forum.legato.io/u/Elmoo)\
**Post date:** [October 23, 2024, 7:34am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/3 "2024-10-23T07:34:30Z")

</div>

Thanks,  
I can try to use ssl with IP address.

However, using my own code to resolve server IP address is a bit whacky solution. Do you have any idea why getaddrinfo fails inside mqttClientService though it worked on my own code just a few lines earlier?

---

<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:** [October 23, 2024, 7:36am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/4 "2024-10-23T07:36:57Z")

</div>

here says it is fixed after legato 20.04:

> [@MQTT Connection issues on WP7702 \[AWS\]](https://forum.legato.io/t/mqtt-connection-issues-on-wp7702-aws/5617/4):
>
> seems related to this one: I remember when I used the httpget sample with WP76 module, there is same problem of getting IP address inside application and this is fixed in later FW with legato 20.04. Currently you might try method to get IP addres inside program:

I assume you are using WP76 module, have you tried in FW17 of WP76 which is using legato 21.05?

(Bear in mind that once module upgraded to FW R17, you cannot go back to FW R16.x)

---

<div class="post-metadata">

**Author:** ![Elmoo](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@Elmoo](https://forum.legato.io/u/Elmoo)\
**Post date:** [October 23, 2024, 7:50am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/5 "2024-10-23T07:50:31Z")

</div>

In vscode leaf environment, I have these packages installed in the profile.

```auto
"packages": {
    "swi-wp76": "5.0.0",
    "wp76-image": "5.0.0"
}

```

Does the firmware update if I change those to use newer version? e.g. 6.0.0?  
And does the firmware update with the OTA update (.update file)?

I have tried to use the newer 6.0.0 but there is some problems with build that I have not figured out yet. But if I can use my own dns resolve at the moment, I try to update the legato version later.

---

<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:** [October 23, 2024, 8:06am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/6 "2024-10-23T08:06:10Z")

</div>

> [@Elmoo](#):
>
> Does the firmware update if I change those to use newer version? e.g. 6.0.0?

you need to update the firmware of the module to R17 first, and then you need to recompile your legato application in leaf to use the package swi-wp76\_6.0.0 which is for the legato version of R17:  
[https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-17/#sthash.SnT6fF1l.dpbs](https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-17/#sthash.SnT6fF1l.dpbs)

> [@Elmoo](#):
>
> And does the firmware update with the OTA update (.update file)?

Firmware update is using spk file, not .update file

---

<div class="post-metadata">

**Author:** ![Elmoo](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@Elmoo](https://forum.legato.io/u/Elmoo)\
**Post date:** [October 23, 2024, 10:19am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/7 "2024-10-23T10:19:18Z")

</div>

Is it possible to update firmware and legato system with a single file or do I need to update firmware.spk and .update separately?

---

<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:** [October 23, 2024, 10:22am UTC](https://forum.legato.io/t/getaddrinfo-fail-inside-the-mqttclientservice/6818/8 "2024-10-23T10:22:30Z")

</div>

then you need to embed your application into legato.cwe

> [@Flash size wp7607](https://forum.legato.io/t/flash-size-wp7607/3805/34):
>
> hi @jyijyi, Thanks for your help earlier. I was able to build \<legate.cwe\> and \<system.wp76xx.update\> file using make wp76xx command. Also I was to add myCustom.adef file and build separately with command: mkapp -t wp76xx apps/sample/myApp/myCustom.adef Now, I am trying to add myCustom.adef to build with make wp76xx command, so that I can create \<system.wp76xx.include.myCustom.update\> file. Is there a way to do it? Could you please advise which file I need to modify? Thanks.

After that combine the legato.cwe with modem and yocto and mcu image into one image by swicwe tool:

[https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-17-components/#sthash.fdXjPVgZ.dpbs](https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-17-components/#sthash.fdXjPVgZ.dpbs)

[https://source.sierrawireless.com/resources/airprime/software/swicwe/](https://source.sierrawireless.com/resources/airprime/software/swicwe/)

Of course, updating the official spk file and then just update you .update file will be easier for you
