This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Getting ERROR: getaddrinfo failed -11 in MQTT connection

Hi Dev team,

I have been working with the MQTT example and building up my application. I establish a successful connection with the broker and everything runs fine for 5-6 days. Then I get the (ERROR: getaddrinfo failed -11 ) error and the MQTT connection does not happen. I looked into the code and found that this error is because the broker's address is not obtained. 

I looked into the errno and found that -11 refers to "No more processes". 

I could not understand why this error comes up suddenly and how could I solve this issue.

Its strange because it comes up after things have been running smoothly. 

Regards,

Adeel.

Parents Reply Children
  • Hi Oyvind,

    I am connecting to a firm's broker and not the open source brokers like HIVE MQ. The connection works perfectly for 6-7 days, probably more than that (there is no specific fixed period after which I get this error).

    The keepalive is set to: 60 seconds. I am normally connecting to the MQTT broker after every hour, sending the data and then disconnecting from the broker.

    I just wanted to know what this addrinfo failed -11 means, as I get it just when the MQTT wants to connect to the broker.

    Regards,

    Adeel.

  • Adeel,

    How do you get it working again? Does it work at all after it return the error?

    What SIM are you using? Have you ensured that there is data on the SIM?

    Kind regards,
    Øyvind

  • Hi Oyvind,

    No, unfortunately it does not work after that. It works again when I manually reset it. 

    I am using 1nce Sim card : https://1nce.com/en/

    Yes, the sim has data, and the application works again after I reset it.

    I read a bit about this error and I think its related to the DNS address not being resolved automatically. 

    https://devzone.nordicsemi.com/f/nordic-q-a/60825/nrf9160-getaddrinfo-return-error--11

    But I wonder how can it happen suddenly after the application has been running smoothly for 6-7 days or more.

    For a work around to make it work smoothly now, I have just added a soft reset (sys_reboot(0)) when I get this error, but I am curious to know the reason of this error. The more stranger thing is that I have about 5 thingys running now and 3 of them had this issue at the same time and the other 2 did not have this issue !!

    So I was looking for the root cause of it that I could resolve.

    Regards,

    Adeel.

  • Hi Adeel, 

    Are you able to provide a modem trace to show when this issues happens? 

    Thanks!

    Kind regards,
    Øyvind

  • Hi Oyvind,

    It would be hard to provide it now as I had to make the device working again. The issue does not have a periodic trend so to say. I have observed it happen after every 6-7 days of deployment, and I have observed it happen twice. 

    The error occurs when I try to connect to MQTT and it goes into the broker_init() function in mqtt library. 

      err = getaddrinfo(hostname, NULL, &hints, &result);
      if (err) {
        printk("ERROR: getaddrinfo failed %d\n", err);
    
        return;
      }

    Normally it directly fetches the IP and MQTT connects, but when this errors occurs- I believe its unable to fetch the IP or so. Issue is when this error occurs, it never resolves itself later on till I reset it. I was hoping for a clean workaround for this (right now I do a soft reboot when I get this).

    Regards,

    Adeel.

Related