Ask, and ye shall receive.
Posts: 2
Joined: 09:32, 04 Dec 2015


Postby steve » 09:44, 04 Dec 2015


I have built a single website page that uses the js plugin "mqttws31.js" to get MQTT messages from cloudMQTT and display them in a webpage. The following html code perfectly in chrome but when running in evothings it won't connect to the server.

I get the following error through evothings console log

LOG: used for debugging
LOG: [object Object]
LOG: error

attached is the following html file

Code: Select all

<!DOCTYPE html>
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, user-scalable=no
      initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />


      @import 'ui/css/evothings-app.css';

   // Redirect console.log to Evothings Workbench.
   if (window.hyper && window.hyper.log) { console.log = hyper.log }
   <script src="cordova.js"></script>
   <script src="libs/jquery/jquery.js"></script>
   <script src="libs/evothings/evothings.js"></script>
<body ontouchstart=""><!-- ontouchstart="" enables low-delay CSS transitions. -->

   <h1>Arduino LED On/Off TCP</h1>
   <script src="mqttws31.js" type="text/javascript"></script>
   <script type="text/javascript">
     // Create a client instance
     client = new Paho.MQTT.Client("", 30989,"client_id");
     //Example client = new Paho.MQTT.Client("", 32903, "web_" + parseInt(Math.random() * 100, 10));

     // set callback handlers
     client.onConnectionLost = onConnectionLost;
     client.onMessageArrived = onMessageArrived;
     var options = {
      useSSL: true,
      userName: "eiyatsta",
      password: "Q0q9xyYeOkcT",

     // connect the client

     // called when the client connects
     function onConnect() {
      // Once a connection has been made, make a subscription and send a message.
      message = new Paho.MQTT.Message("Hello CloudMQTT");
      message.destinationName = "/cloudmqtt";

      console.log("used for debugging");
     function doFail(e){

     // called when the client loses its connection
     function onConnectionLost(responseObject) {
      if (responseObject.errorCode !== 0) {

     // called when a message arrives
     function onMessageArrived(message) {




Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: cloudMQTT

Postby Fredrik » 13:39, 04 Dec 2015

I would change the line "console.log(e);" to "console.log(JSON.stringify(e));" for more detail on the error.

Posts: 2
Joined: 09:32, 04 Dec 2015

Re: cloudMQTT

Postby steve » 16:36, 05 Dec 2015

Hi Fredrik

Thanks for the tip, i made the change you suggested and got the following message

Code: Select all

LOG: {"errorCode":7,"errorMessage":"AMQJS0007E Socket error:undefined."}

I don't know what happened next... but while google-ing the error message it started working, i'm not sure why??

Its working fine now, i'll post another message when i find out the reason for the error in the first place.


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 19 guests