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.
Step 4 of the Python Snake MQTT tutorial says to run python code to connect to 'mqtt.ably.io' mqtt broker.
The code
should trigger the stdout message 'Connected' because the on connect callback prints 'Connected':
But on my system, no 'Connected' message is printed before the python script terminates. I added a
time.sleep(5)afterclient.connect(...)to delay script termination, and 'Connected' now prints, as expected.