Skip to content

Commit c493c7b

Browse files
committed
Add timeout value.
Add `timeout` value to avoid `MMQTTException: loop timeout (0) must be bigger than socket timeout (1))` error.
1 parent 4742286 commit c493c7b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

examples/native_networking/minimqtt_adafruitio_native_networking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def message(client, topic, message):
9090
photocell_val = 0
9191
while True:
9292
# Poll the message queue
93-
mqtt_client.loop()
93+
mqtt_client.loop(timeout=1)
9494

9595
# Send a new message
9696
print(f"Sending photocell value: {photocell_val}...")

examples/native_networking/minimqtt_pub_sub_blocking_native_networking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def message(client, topic, message):
9292
# NOTE: Network reconnection is handled within this loop
9393
while True:
9494
try:
95-
mqtt_client.loop()
95+
mqtt_client.loop(timeout=1)
9696
except (ValueError, RuntimeError) as e:
9797
print("Failed to get data, retrying\n", e)
9898
wifi.reset()

examples/native_networking/minimqtt_pub_sub_blocking_topic_callbacks_native_networking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def on_message(client, topic, message):
104104
# NOTE: NO code below this loop will execute
105105
while True:
106106
try:
107-
client.loop()
107+
client.loop(timeout=1)
108108
except (ValueError, RuntimeError) as e:
109109
print("Failed to get data, retrying\n", e)
110110
wifi.reset()

0 commit comments

Comments
 (0)