【问题标题】:Eclipse-mosquitto "Address not available"Eclipse-mosquitto“地址不可用”
【发布时间】: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,您已经在第一行告诉它将该端口用作侦听器的一部分。

标签: docker mqtt mosquitto


【解决方案1】:

您的启动命令已关闭,但不正确。应该是:

docker run -it \
  -p 1883:1883 \
  --restart always \
  -v /home/juliette/mosquito.conf:/etc/mosquitto/mosquitto.conf \
  --name mqtt \
  eclipse-mosquitto:2.0.7

配置文件位于/etc/mosquitto...除非他们已将其移至版本 2。

您可能还想为 mqtts/TLS 连接添加 -p 8333:8333 行。

编辑:我在您的日志文件输出中看到它说配置是从/mosquitto/config/mosquitto.conf 加载的...所以如果-v /home/juliette/mosquito.conf:/etc/mosquitto/mosquitto.conf 行不起作用,请将其更改为-v /home/juliette/mosquito.conf:/mosquitto/config/mosquitto.conf

【讨论】:

  • 谢谢,这解决了我的问题。我在参数中混淆了本地路径和容器路径的顺序
猜你喜欢
  • 2022-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-10
  • 2017-08-19
相关资源
最近更新 更多