乐鑫技术交流
直播中

岳臻俊

7年用户 984经验值
私信 关注
[问答]

无法连接到MQTT集线器的原因?

嗨,我正在尝试使用 mqtt lib 连接我的本地 mosquitto 服务器,以下代码根本不提供任何输出:
代码:全选m=mqtt.Client(\"nodemcu_box\", 120)

m:connect(\"192.168.1.3\", 1883, 0, function(conn)
    print(\"connected\")
end)

m:publish(\"hello/world\",\"hello from nodemcu\",0,0, function(conn)
    print(\"sent\")
end)


但我可以使用控制台客户端向代理发送消息
代码:全选$ mosquitto_pub -h 192.168.1.3 -p 1883 -d -t hello/world -m \"hello\"

如果我订阅主题,就会收到它。
它不能从 nodemcu 工作的原因可能是什么?


更多回帖

发帖
×
20
完善资料,
赚取积分