 handlers
      client.onConnectionLost = onConnectionLost;
      client.onMessageArrived = onMessageArrived;

      // connect the client
      client.connect({
        userName: "user2",
        password: "password2",
        onSuccess: onConnect,
        onFailure: onFailure
      });

      // called when the client failed to connect
      function onFailure(error) {
        console.log("onFailure:" + JSON.stringify(error));
      }
      // called when the client connects
      function onConnect() {
 