Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Adafruit_MQTT_Subscribe reliability issue
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Adafruit_MQTT_Subscribe reliability issue

by hwiguna on Mon Sep 21, 2015 11:06 pm

Thanks for the MQTT libraries for the ESP8266. It works great with adafruit.io.
However, there appears to be a bug with Adafruit_MQTT_Subscribe. It works most of the time, but about every 8 message received, the message would be lost and the ESP would reconnect.
This happens with the digital_out example with no modifications other than the wifi credentials.
I created the feed and dashboard element as instructed in the sketch comment.
Let me know what I could do to help pinpoint the issue further.

PS: Going the opposite direction works great! I've been able to reliably send button and potentiometer states to adafruit.io.

hwiguna
 
Posts: 28
Joined: Wed Nov 16, 2011 10:33 am

Re: Adafruit_MQTT_Subscribe reliability issue

by tdicola on Tue Sep 22, 2015 7:13 pm

That's odd, just to check though is it the ESP8266 example in the MQTT library here: https://github.com/adafruit/Adafruit_MQ ... sp8266.ino ? If so is it that after changing the subscribed to feed (onoff) 8 times you see the sketch reconnect to AIO and lose the last message?

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Adafruit_MQTT_Subscribe reliability issue

by hwiguna on Tue Sep 22, 2015 11:28 pm

Sorry guys, it's user error! 100% my bad.

I forgot that I was messing with the timeout parameter.
It becomes unreliable because I lowered that timeout to 500.

Leaving timeout at 1000 works FLAWLESSLY.

Does the library support non-blocking check similar to Serial.available()?

hwiguna
 
Posts: 28
Joined: Wed Nov 16, 2011 10:33 am

Re: Adafruit_MQTT_Subscribe reliability issue

by adafruit2 on Wed Sep 23, 2015 11:25 am

at this time no there's no callback support

adafruit2
Site Admin
 
Posts: 19408
Joined: Fri Mar 11, 2005 7:36 pm

Re: Adafruit_MQTT_Subscribe reliability issue

by tdicola on Wed Sep 23, 2015 11:44 am

Oh no problem, glad it was an easy fix. There's no non-blocking mode yet, but you can tweak how long it waits for data to be received by adjusting one of the #define values. For the ESP8266 check out the Adafruit_MQTT_Client.h file and its MQTT_CLIENT_READINTERVAL_MS value: https://github.com/adafruit/Adafruit_MQ ... .h#L29-L30 It's set to 10 milliseconds by default which means to will wait 10 miliseconds at a time for new data to be received. This means you could call readSubscriptions with a 10 millisecond timeout and it would only do one interation (don't pass in a smaller timeout though, it looks like the code wouldn't handle a timeout below the read interval right now). So for example you could experiment with setting the MQTT_CLIENT_READINTERVAL_MS to 1 and then calling readSubscriptions with a 1 or 2 millisecond timeout to do a faster check.

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Please be positive and constructive with your questions and comments.