Topic: PIC32 MQTT state machine lock-up
Hi,
We use wolfmqtt client on pic32 with TLSv1.2.
In some cases (usually related to internet connection problems) we see the following scenario:
The app state machine rolls into MqttClient_NetConnect():
int rc = MqttClient_NetConnect(&appData.myClient, (const char *)&appData.host, sds_web_config.comm_setting.mqtt_port.Val, MQTT_DEFAULT_CMD_TIMEOUT_MS, SDS_TLS/*NULL*/, mqtt_sds_tls_cb/*NULL*/);
Since it fails to connect, timeout of 20 seconds sends the state machine to ERROR state:
case APP_TCPIP_ERROR:
{
/*no matter what the issue is, free the tcp/mqtt resources and re-connect
this will include cases of: cable removal, router disconnects, poor internet connection*/
rc= MqttClient_NetDisconnect(&appData.myClient);
if (rc== MQTT_CODE_SUCCESS)
{
//start all over again including dhcp
appData.state = APP_TCPIP_WAIT_INIT;
/* Free resources */
if (appData.myClient.tx_buf) WOLFMQTT_FREE(appData.myClient.tx_buf);
if (appData.myClient.rx_buf) WOLFMQTT_FREE(appData.myClient.rx_buf);
/* Cleanup network */
MqttClientNet_DeInit(&appData.myNet);
}
}
break;
and goes back to MqttClient_NetConnect() state.
Then after about 20 loops, the MqttClient_NetConnect() function returns NetConnect: Rc=-1, SoErr=111
And from that poin on the MqttClient_NetConnect() function never recovers - therefore when internet connection comes back, state machine gets locked-up in a non-connect state.
In order to bring the mqtt connection back again, we power the board off and then on again
Do you know how can we make the state-machine recover from this lock-up?
Regards,
Gil