Non-negative error code broker_init in mqtt_helper.c

Hi,

While debugging an issue with reconnecting to our Azure server after the network is lost for some time, I found that azure_iot_hub_connect() returned a non-negative error code that I didn't catch correctly since I had the condition if (err < 0) in my code. Through the logs, I found that the error was happening in mqtt_helper_connect() and more specifically in broker_init() which is called from client_connect(). I tried reconnecting before I was connected to the network, which resulted in an error in getaddrinfo(). This error, however, is returned as -err, which results in a positive error code, which invalidates the documentation of mqtt_helper_connect.

I updated my code to catch all errors (if (err != 0)), but still I wanted to raise this to see if this is indeed a bug or intentional.

Parents Reply Children
No Data
Related