mqtt_connect(&client) does not return any value during operation, and the program is stuck in mqtt_connect(&client) and does not come out

When I connected mqtt on nRF9160, I found a strange problem, which caused the device to freeze and become bricked. The location cause was found to appear in err = mqtt_connect(&client), mqtt_connect(&client) does not return any value when running, and the program is stuck mqtt_connect(&client) does not come out. What is going on? It is easy to reproduce after a period of normal operation. The device is running on ncs1.5.1, modem V1.2.3.

Below is my mqtt file:

  • Hi,

     

    There's several configuration(s) and function calls missing from the partial code that you posted, so I am unable to test your scenario. Do you see the same issue with for instance mqtt_simple sample?

     

    Kind regards,

    Håkon

  • Hello, I am glad to receive your reply,

    mqtt_simple did not appear, this problem is not necessarily present, it is occasional, the device itself is working normally, but after working for a period of time, this situation will appear, and many devices appear In this case, the problem is that mqtt_connect(&client) does not return a value and is stuck in this function. How to solve this problem, why this function does not return a value.

  • Call mt_mqtt_connect() in this function and find that the function has no return value. The program stops in this function. According to the log print information, the program stops in the function err = mqtt_connect(&client).

  • Hi,

     

    Based on your problem description, it can be several things that can make connect() hang.

    example: If there is a change in the network state, you can hang in the connect() call for minutes. If you enable the CONFIG_AT_HOST=y and issue "AT+CEREG=5", you will enable notifications when the network state changes for instance.

     

    You are running on an older SDK, do you see similar issues on newer SDK?

    If you still experience issues, could you share a modem trace showing the issue?

     

    Kind regards,

    Håkon

  • This problem is not tested in the latest SDK, because the modem version used by the customer is 1.2.3, which runs on ncs1.3.0. On this version of the SDK, the problem of mqtt connection also exists, because the ncs1.3.0 modem firmware cannot be upgraded. , So customers can only use modem v1.2.3 at present, and the largest SDK supported by modem v1.2.3 is 1.5.1. I also found this problem on SDK 1.5.1. Once this problem occurs, the product crashes and can no longer be normal. It runs, because the program has been stuck at the position where the mqtt connection is not coming out.

Related