You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Adafruit IO's CircuitPython library on a Feather M4 Express with the Airlift FeatherWing. I want to be able to use MQTT/IO pub/sub to subscribe to a topic and publish to another topic in a loop, but the mqtt_client.loop() functions seems to block waiting for data to be posted to the subscribed topic once, then the loop call continues as expected. If I don't 'kick' the subscribed topic by publishing data to this topic from the adafruit.io Feeds screen once, the loop() will eventually throw
MMQTTException: Unable to receive 1 bytes within 60 seconds.
while True:
mqtt_client.loop()
mqtt_client.publish(topic, value)
time.sleep(5)
I tried catching and eating the exception, which works intermittently.
while True:
try:
mqtt_client.loop()
except (MQTT.MMQTTException) as e:
print(e)
mqtt_client.publish(topic, value)
time.sleep(5)
Sometimes it'll work (i.e. exception caught, publish works fine, repeat), other times loop() will throw:
Traceback (most recent call last):
File "code.py", line 142, in <module>
File "code.py", line 140, in <module>
File "adafruit_minimqtt/adafruit_minimqtt.py", line 809, in loop
File "adafruit_minimqtt/adafruit_minimqtt.py", line 569, in ping
File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 82, in send
File "adafruit_esp32spi/adafruit_esp32spi.py", line 721, in socket_write
RuntimeError: Failed to send 2 bytes (sent 0)
The text was updated successfully, but these errors were encountered:
Following brubell's reply to my Forums post in https://forums.adafruit.com/viewtopic.php?f=60&t=175702, I ran my code using the adafruit_minimqtt library from the master branch of the repo, and the loop() function no longer blocks and throws exceptions.
I ran the new library code in both my code that uses the adafruit_minimqtt library and my code that uses the adafruit_io library with the IO_MQTT wrapper, and they both now run as expected (the loop() function no longer blocks).
I'm trying to use Adafruit IO's CircuitPython library on a Feather M4 Express with the Airlift FeatherWing. I want to be able to use MQTT/IO pub/sub to subscribe to a topic and publish to another topic in a loop, but the mqtt_client.loop() functions seems to block waiting for data to be posted to the subscribed topic once, then the loop call continues as expected. If I don't 'kick' the subscribed topic by publishing data to this topic from the adafruit.io Feeds screen once, the loop() will eventually throw
MMQTTException: Unable to receive 1 bytes within 60 seconds.
I'm using the example code in minimqtt_pub_sub_nonblocking_esp32spi.py (from the latest official v6 release of the CircuitPython IO library) at https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT/blob/85d9d846f3fd8f9d3ee8ae354c5c34d2e2970c1a/examples/esp32spi/minimqtt_pub_sub_nonblocking_esp32spi.py
I tried catching and eating the exception, which works intermittently.
Sometimes it'll work (i.e. exception caught, publish works fine, repeat), other times loop() will throw:
The text was updated successfully, but these errors were encountered: