【问题标题】:mosquitto (mqtt broker) is refusing connections over websocketsmosquitto(mqtt 代理)拒绝通过 websockets 进行连接
【发布时间】:2017-01-30 16:55:04
【问题描述】:

我已经设置了一个 mosquitto 代理,但它拒绝通过 websockets 连接 这是我的 conf 文件:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

listener 1883 0.0.0.0 

listener 8008 0.0.0.0
protocol websockets

我在 conf.d 没有任何 conf

使用 PAHO javascript 客户端我得到一个 ERR_CONNECTION_REFUSED

顺便说一句,我使用 debian jessie 作为操作系统

--------------------------编辑 1-------- --------------------------

我已经降低了 iptables,但它仍然无法正常工作。 通常的连接方式是有效的(使用端口 1883) 这是我启动 mosquitto 时的输出

1477788244: mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 10:12:09 +0100) starting
1477788244: Using default config.
1477788244: Opening ipv4 listen socket on port 1883.
1477788244: Opening ipv6 listen socket on port 1883.

【问题讨论】:

  • 您是尝试从与代理相同的机器还是从不同的机器连接?您还启用了防火墙吗?
  • 测试机器与broker不同,因为正常方式(不是websocket)工作,我会检查iptables看它是否阻塞
  • 我已经降低了 iptables 仍然无法正常工作

标签: websocket mqtt mosquitto


【解决方案1】:

启动输出中重要的一行在这里:

1477788244: Using default config.

这表示 mosquitto 正在使用它的内置配置(仅在 1883 上侦听本机 MQTT 流量),甚至不读取您的配置文件。

如果你只是在没有命令行选项的情况下启动 mosquitto,这就是它的用途,它不会在 /etc/mosquitto/ 中查找配置文件。

您需要使用 -c 选项明确告诉 mosquitto 它的配置文件在哪里。

mosquitto -c /etc/mosquitto/mosquitto.conf

根据您安装 mosquitto 的方式,您可能需要编辑在启动时自动启动它的脚本。这可能在这里:/etc/init.d/mosquitto

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 2022-11-14
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 2015-11-25
    • 1970-01-01
    相关资源
    最近更新 更多