Same MQTT Handle for publishing messages and OTA

FreeOurToes wrote on February 26, 2019:

Hello,

Is it logical to have the same MQTT handle for publishing messages to AWS and for OTA updates?

I am using ESP32 and running into a memory issues and trying to figure out where to optimize. And so far I had all other custom apps running and MQTT publisher app and then additionally I was just using OTA demo task for updates.

Thanks

Edited by: FreeOurToes on Feb 26, 2019 7:39 AM

Edited by: FreeOurToes on Feb 26, 2019 7:40 AM

Tiangang-AWS wrote on February 26, 2019:

Hi,

Yes, you can reuse the same MQTT handle for both OTA and publishing messages to AWS.

Please let us know if you run into any issue.

Thanks.

TJirsch wrote on March 17, 2019:

Hi,

I am trying to build an app that combines the shadow and ota library.
When connecting both at the same time, only the last one connecting works correctly.
Using a shared handle is prevented by an assertion in the shadow code.

The shadow client obviously connects to all the $aws/things//update topics and the ota agent does so for $aws/things//jobs/ ones.
The subscriptions by both clients needs to be made with the same client id, because the thingname is used as the topic that gets subscribed to.
This results in duplicate client id errors in the logs.
If I change the thingname for one client, this results in a different mqtt clientid and both “work”, but only the client with the thingname = clientid gets traffic.

Is there a way around that ?

The only other possibility would be to stop shadow traffic and connect the ota agent periodically.

Thank you for your help.

Edited by: TJirsch on Mar 17, 2019 12:10 PM

TJirsch wrote on March 17, 2019:

Found it myself:

Use different ids in xConnectParams.pucClientId for SHADOW_ClientConnect and MQTT_AGENT_Connect, then pass real thingname to OTA_AgentInit.
I use correct thingname with shadow for clientid and thingname in callbacks, and a different name for ota.