【问题标题】:Unable to test Mosquitto Server on Mac无法在 Mac 上测试 Mosquitto 服务器
【发布时间】: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>

标签: macos mosquitto


【解决方案1】:

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

  1. 使用brew link mosquitto 解决了第一个无法启动发布者和订阅者客户端的问题。要查看 brew 链接的工作原理,您可以查看 this 帖子。
  2. 启动 mosquitto 代理服务作为守护程序允许的连接。因此,只需使用 brew services start mosquitto -d 即可。我不知道为什么这会起作用,而不是开始一个正常的过程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-20
    相关资源
    最近更新 更多