我使用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
我解决了使用mosquitto_sub
无法使用brew link mosquitto
的第一个问题。
但我仍然拒绝连接。
经过一些谷歌搜索和尝试不同的事情,我已经找到了两个问题的答案。
brew link mosquitto
解决了第一个无法启动发布者和订阅者客户端的问题。要查看brew链接的工作原理,您可以查看this帖子。brew services start mosquitto -d
作品。我不确定为什么这样做而不是开始正常的过程。