title: Cannot connect to MQTT broker(mosquitto) with Javascript Ionic
body: <p>I tried to bind MQTT with the Ionic framework. When trying to send an MQTT message to the broker (I am publishing), when a click event occurs, I get the following error:</p>
  
  <blockquote>
    <p>"AMQJS0011E Invalid state not connected......"
    "WebSocket connection to 'ws://test.mosquitto.org:8080/mqtt' failed: Error >during WebSocket handshake: net::ERR_CONNECTION_RESET" </p>
  </blockquote>
  
  <p>Please can anyone help me? I cannot find a solution anywhere.</p>
  
  <p>I also tried with port 1883, but the problem remains the same.</p>
  
  <pre><code>var App = angular.module("App",["ionic","ngWebSocket"]);
  
  App.controller("Appctrl",["$scope","$log",Appctrl]);
  
  function Appctrl($scope,$log,$websocket){
  
  $scope.mqtt_on = function() {
  
     client = new Paho.MQTT.Client("test.mosquitto.org",    
     Number(8080),"zsrgdxrgdt");
     client.connect();
     message = new Paho.MQTT.Message("Hello");
     message.destinationName = "test/smit";
     client.send(message);
     alert("ON");
  };
  
  $scope.mqtt_off = function() {
     alert("Off");
  `enter code here`};
  
  };
  </code></pre>