Reputation: 1467
I connect to my mosquitto broker with
client.connect("192.168.1.1",1883,60)
to establish the connection, and the server expects traffic every 60 seconds. The paho documentation refers to a PINGREQ/PINGACK message which I would like to use to keep the connection alive.
Can't find any examples of this - how to do this in python (2.7)?
Upvotes: 0
Views: 3494
Reputation: 59658
The short answer is you don't
The pings are handled by the MQTT Client network loop. You need to start this after connecting. There are 3 ways to run the loop:
client.start_loop()
This starts the network loop on a background threadclient.loop_forever()
This starts the network loop on the current thread and will block forever.client.loop()
this executes one cycle of the network loop and must be called as part of your own loop.Upvotes: 3