【发布时间】:2018-09-07 18:02:27
【问题描述】:
我已经使用 brew 安装了 Mosquitto
brew install mosquitto
并测试是否运行使用
brew services list
输出
Name Status User Plist
mongodb stopped
mosquitto started amit /Users/amit/Library/LaunchAgents/homebrew.mxcl.mosquitto.plist
postgresql stopped
tomcat stopped
但是,当我从 this 答案尝试以下操作时,我得到命令未找到
mosquitto_sub -v -t 'test/topic'
-bash: mosquitto_sub: command not found
我必须安装其他东西才能让它工作吗?
另外,我尝试使用 python 脚本连接到代理,但收到连接被拒绝消息
client = mqtt.Client()
client.on_connect = on_connect_handler
client.on_message = on_message_handler
client.connect("localhost", 1883, 60)
client.loop_forever()
编辑 1
我用brew link mosquitto解决了第一个不能使用mosquitto_sub的问题。
但我仍然收到拒绝连接。
【问题讨论】:
-
您的 Python 脚本无法“按原样”运行,因为您尚未安装或导入 mosquitto 客户端。
-
我已经做到了。我没有将它添加到问题中,因为我认为它是隐含的。不过,我已经找到了答案。感谢您抽出宝贵时间查看。
-
干得好!请将您的结果添加为答案,然后您可以接受自己的答案并获得积分并帮助社区。span>