【问题标题】:Websocket connection error with HiveMQ 2.1.0 + Eclipse Paho javascript mqttws31.jsHiveMQ 2.1.0 + Eclipse Paho javascript mqttws31.js 的 Websocket 连接错误
【发布时间】:2014-10-29 04:42:28
【问题描述】:

在 Google Chrome 上将 mqttws31.js 作为 HTML 文件的一部分执行时,我遇到了以下错误。

HiveMQ 被用作 MQTT 代理,日志如下

2014-10-28 14:46:45,043 INFO  - HiveMQ home directory: E:\hivemq-2.1.0
2014-10-28 14:46:45,065 INFO  - Starting HiveMQ Server
2014-10-28 14:46:48,249 WARN  - No license file found. Using free personal licensing with  restrictions to 25 connections.
2014-10-28 14:46:48,367 INFO  - Activating statistics callbacks with an interval of 60 seconds
2014-10-28 14:46:48,368 INFO  - Activating $SYS topics with an interval of 60 seconds
2014-10-28 14:46:48,728 INFO  - Starting on address 127.0.0.1 and port 1883
2014-10-28 14:46:48,734 INFO  - Started HiveMQ 2.1.0 in 3694ms

当 HTML 文件包含 MQTT 客户端时,会遇到以下错误。

WebSocket connection to 'ws://127.0.0.1:1883/mqtt' failed: Connection closed before receiving a handshake response

对解决此问题的任何帮助表示赞赏。

【问题讨论】:

    标签: mqtt paho libwebsockets hivemq


    【解决方案1】:

    您似乎没有启用 websockets,以便能够将 mqttws31.js 与 hivemq 一起使用。

    在此处查看设置; http://www.hivemq.com/docs/hivemq/2.1.0/#hivemqdocs_configuration_options

    Open conf/configurations.properties with your favorite editor Change websockets.enabled to true

    然后在你的代码中连接到; ws://127.0.0.1:8000/mqtt

    这是 hivemq 网站上的快速操作指南,http://www.hivemq.com/hivemq-mqtt-websockets-support-message-log-plugin-2-min/

    【讨论】:

    • 谢谢。作品!!给人的印象是默认情况下启用此功能,因为我使用 HiveMQ 与 Mosquitto MQTT 代理的原因是缺乏 websocket 支持(虽然 1.4 支持但需要从 bitbucket 获取并生成二进制文件)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-09
    • 1970-01-01
    • 2021-06-08
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 2017-07-16
    相关资源
    最近更新 更多