pcbreflux / espressif

all espressif stuff will committed here
GNU General Public License v3.0
589 stars 442 forks source link

Subsequent Subscribe and Publish in CloudMQTT #16

Open atulpriyadarshi21992 opened 6 years ago

atulpriyadarshi21992 commented 6 years ago

Hi,I was trying to subscribe for messages from CloudMQTT server and do some BLE operation and send the result back using Publish command. But I am facing some issues when I try to publish the data. The error is surfacing some of the time. It seems like the publish command is interfering with MQTTYield command as well. As I get some SSL error 0x7780 sometimes during the publish.

Also sometimes the Yield returns -1(FAILURE) during publish command.

My theory is that the Yield code is considering the Publish acknowledgment as the PING acknowledgement from previous yield command. I tried making the Publish command from another task but the same issue is prevalent. Can anyone help regarding this?

atulpriyadarshi21992 commented 6 years ago

I did a bit more digging.

It turns out that I was using QOS2 as the quality of service for the publish. So it was waiting for all the acknowledgments for that publish command, thus, as a result, the Yield command couldn't be executed thus causing a failure in yield.

I added a ESP_LOG command at everytime keep alive was being called and I got the problem. I am using QOS0 and the problem is not there anymore.

There must be a better way to do that. Please suggest

Here is my Client config

data.clientID = clientId; data.willFlag = 0; data.MQTTVersion = 4; // 3 = 3.1 4 = 3.1.1 data.keepAliveInterval = 5; data.cleansession = 1; data.username = username; data.password = password;