I'm trying to communicate a couple of programmes. I'm getting some troubles when I use the last will function. My code is this:
Suscriber:
import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
print 'Received: ' + msg.payload
client = mqtt.Client()
client.on_message = on_message
client.connect('localhost', 1883)
client.subscribe('hello/#')
client.loop_forever()
Publisher:
import paho.mqtt.client as mqtt
client = mqtt.Client()
client.will_set('hello/will', 'Last will', 0, False)
client.connect('localhost', 1883)
client.publish('hello/world', 'Regular msg', 0, False)
client.disconnect()
The output:
I should receive only the regular message because I use client.disconnect() to close the connection. If I comment the will_set line, I get the regular message. I also tried publishing both on the same topic and it doesn't work. Any guess??