问题解决:检查帖子底部
我无法连接到 websocket。端口 1883 工作正常。这是 MQTT.fx 的输出:
2017-01-21 07:46:26,293 INFO --- BrokerConnectorController : onConnect
2017-01-21 07:46:26,294 INFO --- ScriptsController : Clear console.
2017-01-21 07:46:26,295 INFO --- MqttFX ClientModel : MqttClient with ID MQTT_FX_Client_Websocket assigned.
2017-01-21 07:46:36,314 ERROR --- MqttFX ClientModel : Error when connecting
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) ~[org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_112]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(Unknown Source) ~[?:1.8.0_112]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) ~[org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107) ~[org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
... 1 more
2017-01-21 07:46:36,315 ERROR --- MqttFX ClientModel:Please verify your Settings (e.g. Broker Address, Broker Port & Client ID) and the user credentials!
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) ~[org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_112]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(Unknown Source) ~[?:1.8.0_112]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) ~[org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107) ~[org.eclipse.paho.client.mqttv3-1.1.0.jar:?]
... 1 more
2017-01-21 07:46:36,321 INFO --- ScriptsController : Clear console.
2017-01-21 07:46:36,322 ERROR --- BrokerConnectService : Connection lost
我对服务器和端口进行了 Telnet 测试,得到一个空白终端。我想这意味着有一个连接,因为否则我会有一个“连接失败”。消息日志插件不显示任何内容,日志文件中也没有任何内容。
它的 Debian 和 HiveMQ 3.2.2。
JAVA_OPTS: -Djava.net.preferIPv4Stack=true -XX:-UseSplitVerifier -noverify -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/hivemq/heap-dump.hprof
-------------------------------------------------------------------------
2017-01-21 07:37:02,159 INFO - Starting HiveMQ Server
2017-01-21 07:37:02,176 INFO - HiveMQ version: 3.2.2
2017-01-21 07:37:02,178 INFO - HiveMQ home directory: /opt/hivemq
2017-01-21 07:37:02,226 INFO - Log Configuration was overridden by /opt/hivemq/conf/logback.xml
2017-01-21 07:37:12,013 INFO - Loaded Plugin HiveMQ JMX Metrics Reporting Plugin - v3.0.0
2017-01-21 07:37:12,014 INFO - Loaded Plugin HiveMQ MQTT Message Log Plugin - v3.0.0
2017-01-21 07:37:12,014 INFO - Loaded Plugin HiveMQ Sys Topic Plugin - v3.0.0
2017-01-21 07:37:12,014 INFO - Loaded Plugin HiveMQ JVM Metrics Plugin - v3.1.0
2017-01-21 07:37:12,038 INFO - JMX Metrics Reporting started.
2017-01-21 07:37:12,099 INFO - JMX Metrics Reporting started.
2017-01-21 07:37:12,109 INFO - Starting TCP listener on address 192.168.0.12 and port 1883
2017-01-21 07:37:12,131 INFO - Starting Websocket listener on address 192.168.0.12 and port 8000
2017-01-21 07:37:12,139 INFO - Started TCP Listener on address 192.168.0.12 and on port 1883
2017-01-21 07:37:12,139 INFO - Started Websocket Listener on address 192.168.0.12 and on port 8000
2017-01-21 07:37:12,140 INFO - Started HiveMQ in 9967ms
2017-01-21 07:37:12,142 INFO - No valid license file found. Using evaluation license, restricted to 25 connections.
编辑
好的,这是一个 Nginx 问题,因为没有 SSL,我的 JavaScript 站点可以正常工作。正如我在这里看到的那样,应该可以对 http 使用 SSL 而对 websockets 使用不安全:
我尝试了那里的配置,但没有运气。
解决方案: HiveMQ 不需要 Nginx 代理。问题是 Firefox 不接受 websockets 的自签名证书。将“network.websocket.allowInsecureFromHTTPS”设置为 true 将使其工作。在 Chrome 中,您会收到有关 JavaScript 安全性的消息,您可以接受它。因为我只使用 Firefox 并且没有消息,所以花了几个小时才发现出了什么问题。paho onFailure 功能也没有出现。