未交付MQTT Python QOS 0

未交付MQTT Python QOS 0,mqtt,paho,Mqtt,Paho,我使用的paho mqtt库具有以下发布者代码: def on_publish(client, userdata, mid): print dir(userdata) print "published"+str(userdata ) client.disconnect() mqttc = mqtt.Client() # There's normally no need to set a client id. mqttc.on_publish = on_publish m

我使用的paho mqtt库具有以下发布者代码:

def on_publish(client, userdata, mid):
    print dir(userdata)
    print "published"+str(userdata )
    client.disconnect()

mqttc = mqtt.Client() # There's normally no need to set a client id.
mqttc.on_publish = on_publish
mqttc.connect("localhost", 1883, 60)
mqttc.publish("hello/world", "Hello, World", 0)
mqttc.loop_forever()
我确实在代理日志中看到了客户机已连接和已断开连接的消息,但在on_publish()中,用户数据似乎没有

从hivemq mqtt web客户端发布QoS=0也可以正常工作

我的订户代码是:

def on_connect(client, userdata, rc):
    client.subscribe("hello/world", 0)

def on_message(client, userdata, msg):
    print "Topic: ", msg.topic+'\nMessage: '+str(msg.payload)

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.on_log = on_log

client.connect("localhost", 1883, 60)

client.loop_forever()

如果您从未设置过userdata,我们将非常感谢您的任何建议,因此毫不奇怪它是空的。有关userdata的更多详细信息,请参阅。谢谢@ralight。我误以为里面有有效载荷。然而,这并不能解释什么信息没有被打印出来。它对我很有用。。。您可以将代理日志粘贴到看到连接和断开连接消息的位置吗?