我正在使用这个python脚本来实现Paho(MQTT)订户,但是我无法获得任何responce消息
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("*********")
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("*********", 8883, 60)
client.loop_forever()
当我在上面运行python脚本时,它不会响应任何错误或消息,而是继续循环,我也会逐行运行它,当我运行client.connect("*********", 8883, 60)
时,它只显示0。请注意,没有psk和psk身份,我们无法连接到代理。在
谢谢
请仔细检查您的主题,有时会遗漏/或导致此问题。在
或者
试试这个
相关问题 更多 >
编程相关推荐