Javascrip paho webclient with hivemq account URI not working

Hi,

thank you for your quick reply. I couldn’t manage to use your suggestion, but after some additional search on Internet I found the following article:

it works now in the following version:

<script type='text/javascript' src='paho-mqtt.js'></script>

<script>
var client = new Paho.Client("wss://[alphanumeric code].s2.eu.hivemq.cloud:8884/mqtt", "i");
client.connect({
   userName : "userid",
   password : "password",
   onSuccess:function(){
      console.log('Connected');
      client.subscribe('/test_web');
      message = new Paho.Message("Hello");
      message.destinationName = "/test_web";
      client.send(message); 
   }
 }); 

After loading the page, I receive the message on the HiveMQ webclient and I manage to receive on the html page the message after having added the right client.onMessageArrived function.

Thank you again for your answer.

have a nice day!

1 Like