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.

CC3220SF: Mqtt Client example doenst reconnect to broker if URL is used instead of IP4

Part Number: CC3220SF


Hello!

I found out that if I use

MQTTClient_ConnParams Mqtt_ClientCtx =
{
MQTTCLIENT_NETCONN_URL,
SERVER_ADDRESS,
PORT_NUMBER, 0, 0, 0,
NULL
};

instead of 

MQTTClient_ConnParams Mqtt_ClientCtx =
{
MQTTCLIENT_NETCONN_IP4,
SERVER_IP_ADDRESS,
PORT_NUMBER, 0, 0, 0,
NULL
};

Reconnection to broker doenst happen.

I use my phone as AP and SimpleLink as station, if I turn off just internet on phone, connection to broker restores when I turn it on again.

But if I turn off AP on my phone, connection to broker is never restored.

This issue happens only if I use URL instead of IP4.

Why does it happen and how could I fix it?

Regards, 

Boris

  • Oh, I am sorry I've changed

    while(g_usConnectIndex < 10)
    {
    sleep(1);

    if(IS_CONNECTED(g_ulStatus) && IS_IP_ACQUIRED(g_ulStatus))
    {
    break;
    }
    g_usConnectIndex++;
    }

    to
    while(!(IS_CONNECTED(g_ulStatus)) || !(IS_IP_ACQUIRED(g_ulStatus)));

    And
    while(!(IS_CONNECTED(g_ulStatus)) || !(IS_IP_ACQUIRED(g_ulStatus)))
    {
    sleep(1);

    if(g_usConnectIndex >= usConnTimeout)
    {
    break;
    }
    g_usConnectIndex++;
    }
    to
    while(!(IS_CONNECTED(g_ulStatus)) || !(IS_IP_ACQUIRED(g_ulStatus)));


    And I guess the lack of sleep-func lead to my issue;

    Anyway if i insert speep(2) after
    gApConnectionState = Mqtt_IF_Connect();
    Everything works fine.

    Could anybody describe why it works that way?

    Regards,
    Boris
  • Hi Boris,

    Thanks for coming back with the solution to your issue.
    I am not sure why a sleep after Mqtt_IF_Connect() allows you to reconnect successfully. Perhaps a delay is needed to prevent some race condition somewhere from making the reconnect fail.

    Regards,
    Michael