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:

Parents Reply Children
  • Hi,

    I did not close the socket . I used the mfw_nrf9160_1.2.7 firmware in ncs1.6.0 (nrf_modem library has been upgraded to v1.0.3). After a day of testing, the problem still reappeared, but it did not solve the problem. Encountered a new bug, please take a look at what is going on, thank you!

  • Hi,

     

    george.zhou said:
    I did not close the socket

    You should close the socket, via the mqtt_disconnect() or mqtt_abort(). If not, you risk leaving the old socket still open after the mqtt_connect() call.

    george.zhou said:
    After a day of testing, the problem still reappeared, but it did not solve the problem. Encountered a new bug, please take a look at what is going on, thank you!

    Which new bug did you observe?

     

    Kind regards,

    Håkon

  • Tested according to the method you said, and did not solve the problem, indicating that the problem I encountered is different from the problem you mentioned, and it should be a new problem.

    First of all, the connection to mqtt is blocked, and I did not reconnect to mqtt because the program is stuck in the mqtt connection and does not return, but once the mqtt connection is successful, I will use mqtt_disconnect() to close the socket after sending the data.I can make sure that the socket is closed every time before connecting mqtt

  • Hi,

     

    Could you try setting these configurations to see if the scenario improves?

    CONFIG_NRF_MODEM_LIB_SENDMSG_BUF_SIZE=2048
    CONFIG_NRF_MODEM_LIB_HEAP_SIZE=2048

     

    Kind regards,

    Håkon

  • Hi,

    I added the two macros you mentioned and tested them for a day on ncs1.6.0 and mfw_nrf9160_1.2.7, and found that the problem was improved. Some get stuck for 3 and a half minutes and return an error code, and sometimes get stuck for more than ten minutes and return an error code. The error returned is EINVAL. I will test for a few more days to see if the problem is completely solved. If it does solve the problem, I will test again on ncs1.5.1 and mfw_nrf9160_1.2.3 to see if this problem can also be solved. I will reply to the results after the test to you, thank you so much!

Related