WebSocket connection to 'ws://test.mosquitto.org:8080/mqtt' failed
18:37 13 Dec 2022

There are similar questions on stackoverflow asked on this topic, and I have read through them all but still can't see what I am doing wrong.

I am trying to connect with (for now) the mosquitto test broker, using websockets. As far as I can see, I have the correct host and port setup.

I created file websockets-4.htm (which I have pasted at the bottom of this post), and when I open it, I get the following feedback:

connecting to test.mosquitto.org
WebSocket connection to 'ws://test.mosquitto.org:8080/mqtt' failed
  k._doConnect @mqttws31.min.js:36
  k.connect @mqttws31.min.js:31
  I.connect @mqttws31.min.js:65
  MQTTconnect @websockets-4.htm:53
  (anonymous) @websockets-4.htm:61

Can anyone see what I am doing wrong?

Here is the websockets-4.htm file:

(Note: I just added a function to be called on 'client.onFailure', however I am not even sure if this is a valid property)



  MQTT WebSocket Example
  
  
  


  

Main Body

websocket mqtt