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
  • Hi Adeel,

    can you please provide more output from the log? What MQTT broker are you trying to connect? What is the MQTT keepalive set to?

    Thanks.
    -Øyvind

  • 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.

  • 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.

  • Hi Adeel, 

    Adeel said:
    Normally it directly fetches the IP and MQTT connects, but when this errors occurs- I believe its unable to fetch the IP or so

    Have you verified that the connection is not lost, or that the broker is online? That is what our developers are asking.

    Thanks.
    -Øyvind 

  • Hi Oyvind,

    Yes the broker is online. I verified that as I could connect to it through MQTT.fx . Also, out of the 5 devices that I have, 3 had this getaddrinfo failed issue while the other 2 were working perfectly. I had started all 5 of them at the same time. 

    Could it be due to the SIM ? I have sim from 1NCE in all my Thingys. 

    Regards,

    Adeel.

  • Adeel, 

    Adeel said:
    Could it be due to the SIM ? I have sim from 1NCE in all my Thingys.

    Are you using PSM/eDRX? If you are not able to provide modem trace, are you able to provide log output?

    Thanks.
    -Øyvind

  • Hi Oyvind,

    Yes, I am using PSM in my application.

    I will keep this ticket on hold and provide you with the log output once I face the same issue again, as I do not have the log output as of now. 

    Regards,

    Adeel.

Reply Children
Related