Mosquitto 1.4.2 Websocket 支持

Mosquitto 1.4.2 Websocket support

我正在尝试利用 Mosquittos 最近的更新来支持代理中的 websockets。我是 运行 Mosquitto v1.4.2,我已将以下行添加到 mosquitto 配置文件 (mosquitto.conf):

listener 10001 127.0.0.1
protocol websockets

listener 1883
protocol mqtt

当我尝试使用新配置启动代理时,我得到以下信息:

$ mosquitto -c /etc/mosquitto/mosquitto.conf
Error: Websockets support not available.
Error found at /etc/mosquitto/mosquitto.conf:16.
Error: Unable to open configuration file.

我假设 Mosquitto 的 1.4 及更高版本现在支持 websocket(不必像 v1.4 之前那样从源代码构建以启用 websocket 支持)所以我想知道我在做什么失踪了。如果您能帮助解决问题,我们将不胜感激。

编辑:忘了说我是 运行 CentOS6

虽然 1.4.x 代码库包含 Websocket 支持,但它必须在构建时启用并依赖于 libwebsocket 库。

RedHat/Fedora yum 存储库中当前可用的构建没有启用 Webosockets,因为没有可用的 libwebsocket 包。我假设 CentOS 使用相同的 srpms。

有关详细信息,请参阅此 bugzilla enrty:https://bugzilla.redhat.com/show_bug.cgi?id=1197678

你可以这样修改config.mk

在config.mk

# Build with websockets support on the broker.
WITH_WEBSOCKETS:=yes

那你可以使用配置参数吗

listener 10001 127.0.0.1
protocol websockets

在目录 mosquitto-1 中。4.X 编辑文件 config.mk:

# Build with websockets support on the broker.
WITH_WEBSOCKETS:=yes

然后在目录 mosquitto-1 中 运行。4.X

make
sudo make install

编辑配置/etc/mosquitto/mosquitto.conf

listener 10001 127.0.0.1
protcol websockets

并重启

mosquitto -c /etc/mosquitto/mosquitto.conf