无法在Mac上测试Mosquitto Server

问题描述 投票:1回答:1

我使用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的第一个问题。

但我仍然拒绝连接。

macos mosquitto
1个回答
5
投票

经过一些谷歌搜索和尝试不同的事情,我已经找到了两个问题的答案。

  1. 使用brew link mosquitto解决了第一个无法启动发布者和订阅者客户端的问题。要查看brew链接的工作原理,您可以查看this帖子。
  2. 作为守护进程启动mosquitto代理服务允许连接。所以简单地使用brew services start mosquitto -d作品。我不确定为什么这样做而不是开始正常的过程。
© www.soinside.com 2019 - 2024. All rights reserved.