Hi.
I’m working with the Shadow demo over ethernet and after starting the demo, after a few minutes, the console shows the following error messages:
I have been reading this thread where it seems to me that it is a similar or equal situation:
The solution he proposes is the following:
void mqttTask(...) {
IotMqtt_Init();
AwsIotShadow_Init(0);
_establishMqttConnection(...);
_modifySubscriptions(...);
_setShadowCallbacks(...);
while(1) {
if(reconnect_to_mqtt) {
AwsIotShadow_Cleanup();
AwsIotShadow_Init(0);
_establishMqttConnection(...);
_modifySubscriptions(...);
_setShadowCallbacks(...);
reconnect_to_mqtt = false;
}
}
}
void someKindOfWiFiReconnectCallback(...) {
//This cleans up a bunch of MQTT resources and triggers the disconnect callback.
IotMqtt_Disconnect(mqttConnection, 0);
}
void mqttDisconnectCallback(...){
//Set flag or post message to trigger re-connect in task that originally setup mqtt connection
reconnect_to_mqtt = true;
}
I have tried to make similar lake in RunShadowDemo function as follows:
int RunShadowDemo( bool awsIotMqttMode,
const char * pIdentifier,
void * pNetworkServerInfo,
void * pNetworkCredentialInfo,
const IotNetworkInterface_t * pNetworkInterface )
{
....
if( status == EXIT_SUCCESS )
{
/* Mark the libraries as initialized. */
librariesInitialized = true;
status = EXIT_FAILURE; //So that it enters the while loop at least once
while (EXIT_FAILURE == status)
{
/* Establish a new MQTT connection. */
status = _establishMqttConnection( pIdentifier,
pNetworkServerInfo,
pNetworkCredentialInfo,
pNetworkInterface,
&mqttConnection );
}
}
if( status == EXIT_SUCCESS )
{
...
}
}
But this solution would only be if the problem occurs when starting the demo, I can’t identify where I could do something similar when the demo is already running.
Any suggestion?