tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

Python Snake tutorial Step 4 does not show MQTT "Connected"

Open Soccertanker opened this issue 4 years ago • 0 comments

Step 4 of the Python Snake MQTT tutorial says to run python code to connect to 'mqtt.ably.io' mqtt broker.

The code

client.loop_start()
   client.connect('mqtt.ably.io', port=8883, keepalive=15)

should trigger the stdout message 'Connected' because the on connect callback prints 'Connected':

def on_connect(client, userdata, flags, rc):
  print('Connected')

But on my system, no 'Connected' message is printed before the python script terminates. I added a time.sleep(5) after client.connect(...) to delay script termination, and 'Connected' now prints, as expected.

Soccertanker avatar Nov 17 '21 06:11 Soccertanker