Guest User

Untitled

a guest
Apr 15th, 2018
206
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
  6. <script type="text/javascript">
  7. var mqtt;
  8. var reconnectTimeout = 2000;
  9. // var host = "m13.cloudmqtt.com";
  10. // var port =33942;
  11. var host = "iot.eclipse.org";
  12. var port =443;
  13.  
  14. function onConnect(){
  15. console.log("Connected");
  16. message = new Paho.MQTT.Message("hello world");
  17. message.destinationName = "esp/test";
  18. mqtt.send(message);
  19. }
  20. function MQTTconnect(){
  21. console.log("connecting to "+host+" "+port);
  22. mqtt = new Paho.MQTT.Client(host,port,"clientjs");
  23. var options = {
  24. timeout: 3,
  25. onSuccess: onConnect,
  26. //userName: "cnukrvlx",
  27. //password: ""
  28. };
  29. mqtt.connect(options);
  30. }
  31. </script>
  32. </head>
  33. <body>
  34. <h1>BODY</h1>
  35. <script type="text/javascript">
  36. MQTTconnect();
  37. </script>
  38.  
  39. </body>
  40. </html>
RAW Paste Data