-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Still trying to suss out what is going on here.
At the simplest level, I'm seeing that mqtt_client.loop()
usually only fetches a single message from the queue (for a particular topic), even if there are many messages waiting. I assume this is incorrect behaviour
I have seen that sometimes it does a 'catch up' and fetch all of the messages!
Not sure if this is a quirk of AdafruitIO's MQTT broker or this library.
e.g. if I run loop() every 5 seconds, expecting a message from AIO's time/seconds
topic
MQTT time: 1649762379
sleep 5
MQTT time: 1649762380
sleep 5
MQTT time: 1649762381
sleep 5
MQTT time: 1649762382
sleep 5
MQTT time: 1649762383
sleep 5
MQTT time: 1649762384
sleep 5
MQTT time: 1649762385
sleep 5
MQTT time: 1649762386
sleep 5
MQTT time: 1649762387
sleep 5
MQTT time: 1649762388
sleep 5
MQTT time: 1649762389
sleep 5
MQTT time: 1649762390 <--------- Here it is very out of sync with the actual time, but then it suddenly does a catch up
sleep 5
MQTT time: 1649762391
MQTT time: 1649762392
MQTT time: 1649762393
MQTT time: 1649762394
....
MQTT time: 1649762436
MQTT time: 1649762437
MQTT time: 1649762438
MQTT time: 1649762439
sleep 5
MQTT time: 1649762440
sleep 5
MQTT time: 1649762441
sleep 5
It looks like if the queue builds up too much, it can cause other issues.
e.g. I'm trying to use MQTT and HTTP requests in the same code, there is an interaction where I see errors like:
Traceback (most recent call last):
File "ssl_debug.py", line 44, in <module>
File "adafruit_requests.py", line 752, in get
File "adafruit_requests.py", line 693, in request
File "adafruit_requests.py", line 546, in _get_socket
RuntimeError: Sending request failed
Which seem to be associated with the MQTT queue not being cleared