This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC3200: CC3200 : MQTT Reconnection

Part Number: CC3200


Tool/software: Code Composer Studio

Hello,

I have written the code with the help of MQTT_CLIENT example project. My code works fine with MQTT reconnection in case of low internet connection. But it does not connect to the broker after WiFi re-connection. After reconnecting with WiFi, code gets stuck at MQTT broker connection and prints 3C: FH-B1 0x10 to net 16, Sent (52 Bytes) [@ 0]. What should be the ideal flow for MQTT reconnection in CC3200? 

  • Hi,

    Can you describe how your application is currently handling the MQTT client setup / connection after the Wi-Fi disconnect and reconnect sequence? Is it the same as in the example?

    Generally speaking, there is no reconnection flow that should be specific to our device. It should be based on the requirements of the server/options used by the client. For example, the device should be able to simply reconnect the same way as it initially connected and resubscribe to topics when using a "clean session" if the MQTT server supports client takeover.

    If you see that this sequence is not working in the demo under some circumstances, perhaps there is an issue in the code with recreating the client context and reconnecting.

    Best Regards,
    Ben M
  • Hi Benjamin,

    Whenever device connects to the internet, MQTT functionality should start. 

    while(1){

    if(Connect_To_Wifi() == true)

    Start_MQTT();

    }

    I have used the example code for implementation, I do not need queue part of the code, so I have removed that code. Initially the MQTT code is working as per the expectation. But in case of MQTT re-connection ( AFTER WiFi re-connection), device is unable to connect to the broker. If I use function "sl_ExtLib_MqttClientDisconnect" in label at the end of MQTTClient function, the code will stop after disconnection and nothing happens after that. 

    I tried using  "sl_ExtLib_MqttClientExit()" in "sl_MqttDisconnect" callback, but at re-connection case the code stops at connection part. Similarly, fucntion "sl_ExtLib_MqttClientCtxDelete()" causes similar issues(there are some MUTEX lock issues with sl_ExtLib_MqttClientCtxDelete function). 

    What approach can be used to resolve the issue?

    thanks, 

    Trupti.

  • Hi Trupti,

    Trupti Jadhav said:
    Similarly, fucntion "sl_ExtLib_MqttClientCtxDelete()" causes similar issues(there are some MUTEX lock issues with sl_ExtLib_MqttClientCtxDelete function).

    Please elaborate on this. What mutex lock issues? This is how the current mqtt_client example currently handles the disconnection/reconnection and it works well from my testing.

    Are you not using an RTOS at all?

    Thanks,

    Ben M

  • Hi Trupti,

    I haven't heard back from you in a while so I assume you have moved on from this issue. I'm going to close this thread. If you have additional questions regarding this topic, you can open the thread up again by posting a new reply. If the thread locks before you get back to it, you can open a new thread referencing this post with the "Ask a related question" button up top.

    Best,
    Ben M