adafruit / Adafruit_CircuitPython_MiniMQTT

MQTT Client Library for CircuitPython
Other
72 stars 50 forks source link

can not make mqtt_client.loop() shorter as 1 sec #195

Closed MyRaspberry closed 5 months ago

MyRaspberry commented 6 months ago

i try:

ts=time.monotonic()
#mqtt_client.loop() # every second check if remote command comes in
mqtt_client.loop(timeout=0.01)
print(f"___ mqtt_client loop {(time.monotonic()-ts)} sec")

more see: test GIT of mqtt pub sub REMOTE BLINKY

vladak commented 5 months ago

Do you explicitly set socket_timeout and recv_timeout when initializing the MQTT object ?

vladak commented 5 months ago

Looking into the linked code this appears to be the case. This is not going to work, you need to reduce socket timeout below the loop timeout, because default socket timeout is 1 second.