我已经在一个全新的Raspberry Pi上安装了Mosquitto . 操作系统是Raspbian . 我按照Owntracks网站上的说明进行操作 .
经纪人在localhost上侦听端口1883 . 使用用户名和密码我可以在一个ssh会话中运行mosquitto_sub到Pi,并接收mosquitto_pub从另一个ssh会话发送的消息 .
代理也在监听端口8883.我使用Owntracks repository中的脚本创建了证书 .
当我在Pi上运行mosquitto_pub时,使用主机名或IP地址我收到错误“错误:连接被拒绝” . 当我使用localhost或127.0.0.1时,错误是“发生了TLS错误 . ” .
如果我在台式计算机上运行mosquitto_pub(与Pi在同一个局域网中),则错误为“连接被拒绝” . 我在这里运行的命令是
mosquitto_pub -t owntracks / test -m测试-h pi1 --cafile ca.crt
其中pi1是运行代理的Pi的主机名 . ca.crt文件从Pi复制到台式计算机 .
Mosquitto日志没有显示连接被拒绝的原因 .
Mosquitto配置中的TLS设置如下所示:
listener 1883 127.0.0.1 listener 8883 cafile /etc/mosquitto/ca_certificates/ca.crt certfile /etc/mosquitto/certs/server.crt keyfile /etc/mosquitto/certs/server.key require_certificate false
我的设置有什么问题?
2 回答
如果您尝试将TLS与mosquitto一起使用,则必须将此选项添加到命令“-p 8883”以指示端口,并且您不需要输入“-h localhost或pi”,因为您在同一个命令中使用了客户端命令mosquitto_pub运行mosquitto broker的机器然后你的命令我们将:“mosquitto_pub -d -u username -P password -t / path / to / the / topic --cafile / path / to / the / certificate -p 8883不要忘了评论这一行
听众1883
在你的mosquitto.conf中
重新创建所有证书解决了问题 . 显然我在包括本地与远程IP地址和主机名方面做错了 . TLS错误消息的信息量不大,但这可能与安全预防措施有关 .