0

Problem solved: check bottom of posting

I cant connect to websockets. Port 1883 works fine. This is the output from 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

I made a Telnet test to the server and port and get a blank terminal. I guess that means there is a connection because otherwise i would have a "connect failed". The message log plugin shows nothing and there is nothing in the log file.

Its Debian and 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.

EDIT

Ok it's a Nginx problem because without SSL my JavaScript site works. It should be possible to use SSL for http and none secure for the websockets as i can see here:

Nginx MQTT websocket proxy 1

Nginx MQTT websocket proxy 2

I tried there configuration but had no luck.

Solution: There is no need for an Nginx proxy with HiveMQ. The Problem is that Firefox does not accept the self signed certificate for websockets. Setting "network.websocket.allowInsecureFromHTTPS" to true will make it work. In Chrome you get a message about JavaScript security and you can accept it. Since i only use Firefox and there is no message it took hours to find out what was wrong. Also the paho onFailure function didn't show up.

MrGlasspoole
  • 415
  • 2
  • 4
  • 15

1 Answers1

0

unfortunately websocket support has not been implemented into MQTT.fx yet.

You will have to use a different MQTT-client, if you insist on connecting via websocket.

Cheers,

Florian, from the HiveMQ Team.

fraschbi
  • 533
  • 3
  • 6
  • Also with mqtt-spy it does not work. # netstat -na | grep 8000: tcp 0 0 192.168.0.12:8000 0.0.0.0:* LISTEN – MrGlasspoole Jan 22 '17 at 08:51
  • Can you try [The HiveMQ Websocket Client](http://www.hivemq.com/demos/websocket-client/) ? – fraschbi Jan 22 '17 at 09:20
  • Thats the problem I'm trying to solve. My local website (paho.js) does not work so I'm trying it with clients. Also tried it with domain in mqtt-spy. Output of ~# lsof -iTCP:8000: java 27019 root 687u IPv4 1190757 0t0 TCP hellgate.skulltronics.net:8000 (LISTEN) – MrGlasspoole Jan 22 '17 at 10:20
  • Ok, did open the firewall made a port forward and it works from your site to my ISP IP. So why does mqtt-spy and the site that is on the same server as HiveMQ not work. – MrGlasspoole Jan 22 '17 at 10:34
  • 1
    I found the problem. I forward 80 (http) to 443 (ssl) in Nginx. So https with non secure websockets do not work? Don't know why mqtt-spy does not work but using http works. – MrGlasspoole Jan 22 '17 at 11:07
  • I did start the debugger in IE11 and Firebug in FX and with https paho.js stops with SecurityError at line 979: this.socket = new WebSocket(wsurl, ["mqtt"]); – MrGlasspoole Jan 23 '17 at 13:31