我想通过 mosquitto 库使用 MQTT 协议(protocol)。
首先,我想做一些安装 mosquitto-clients 的测试
sudo apt-get install mosquitto-clients
本程序提供两种“方法”:
- mosquitto_pub
- mosquitto_sub
正在关注 this说明我正在尝试提交新主题:
mosquitto_sub -d -t newtopic/test
使用默认主机/端口 [localhost/1883]。
我得到:
Error: Connection refused
作为错误太笼统了..任何人都可以帮助我吗?
可能是防火墙问题?在这种情况下,我该如何检查这是否是问题所在?
我正在使用 linux ubuntu ( 3.8.0-42-generic#62~precise1-Ubuntu)
nb 使用 libmosquitto 编写自定义程序的行为相同。
最佳答案
mosquitto_pub/sub 的默认主机:端口组合是 localhost:1883。如果您的本地计算机上没有运行代理,那么它当然无法连接。
解决方案是在您的本地计算机上运行代理,或者告诉实用程序连接到哪里。例如:
mosquitto_sub -t newtopic/test -h test.mosquitto.org
关于linux - mosquitto-client 获取拒绝连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24556160/