与HiveMQ 2.1.0 + Eclipse Paho javascript mqttws31.js的Websocket连接错误

Sud*_*dhi 1 mqtt hivemq libwebsockets paho

在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
Run Code Online (Sandbox Code Playgroud)

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

WebSocket connection to 'ws://127.0.0.1:1883/mqtt' failed: Connection closed before receiving a handshake response
Run Code Online (Sandbox Code Playgroud)

任何解决这个问题的帮助表示赞赏.

Mat*_*tt. 5

看起来你没有启用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/