【发布时间】:2021-03-17 06:43:51
【问题描述】:
我是 mqtt 的新手,正在尝试简单地启动一个我可以测试的本地实例。
执行时
docker run -it -p 1883:1883 --restart always -v mosquitto.conf:/home/juliette/mosquito.conf --name mqtt eclipse-mosquitto:2.0.7
我得到以下输出:
1615963221: mosquitto version 2.0.7 starting
1615963221: Config loaded from /mosquitto/config/mosquitto.conf.
1615963221: Starting in local only mode. Connections will only be possible from clients running on this machine.
1615963221: Create a configuration file which defines a listener to allow remote access.
1615963221: Opening ipv4 listen socket on port 1883.
1615963221: Opening ipv6 listen socket on port 1883.
1615963221: Error: Address not available
1615963221: mosquitto version 2.0.7 running
并且无法与 mqtt-client 连接:
mqtt sub --topic test
Server closed connection without DISCONNECT.
据我发现,当没有配置侦听器但我确实配置了一个侦听器时显然会发生错误,这是我的蚊子.conf:
listener 1883
allow_anonymous true
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
port 1883
我还尝试将端口更改为 8883,因为在一篇帖子中有人提到更大的端口可能会解决问题,但这也没有用。
谁能告诉我我做错了什么?
【问题讨论】:
-
从配置文件末尾删除
port 1883,您已经在第一行告诉它将该端口用作侦听器的一部分。