我使用 WSO2 Message Broker 创建了一个示例发布和订阅模型项目。
import threading
import paho.mqtt.client as mqtt
def publish_1(client,topic):
message="on"
print("publish data")
client.publish(topic,message)
publish_1(client,topic)
broker="localhost"
topic_pub='/temperature123'
topic_sub='$SYS/#'
def on_connect(client, userdata, rc):
print("Connected with result code "+str(rc))
client.subscribe(topic_sub)
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(broker, 1883, 60)
thread1=threading.Thread(target=publish_1,args=(client,topic_pub))
thread1.start()
但是这个实现没有安全性。
有人可以帮我在 WSO2 消息代理中的 MQTT 订阅中设置身份验证吗?而且我在 WSO2 消息代理应用程序https://localhost:9443/carbon中也没有看到任何订阅的节点信息