title: Worklight - Paho MQTT Javascript: Always timeout on Android device and works in simulator
body: <p>I have a Worklight project that uses Paho MQTT Javascript 'mqttws31.js'.</p>
  
  <p>In the simulator everything works fine, but when connecting from a device it always gives me a timeout. </p>
  
  <p>When I connect to the broker through the app called 'MyMQTT' on the device it connects fine. I can't get it to work with Javascript. </p>
  
  <p>I tested if websockets are supported with this code - <a href="http://pic.dhe.ibm.com/infocenter/wmqv7/v7r5/index.jsp?topic=/com.ibm.mm.tc.doc/tc10110_.htm" rel="nofollow">Link</a>
  The webview in the application supports websockets, so that could not be the problem.</p>
  
  <p>I tried several connection options, but it always times out. </p>
  
  <p>Are there some Android permissions I have to add? </p>
  
  <p>I added one of the examples I tried below.</p>
  
  <p>The broker that I use is HiveMQ and I enabled websocket support on port 8000.</p>
  
  <p>I also tried to connect to a public broker - test.mosquitto.org", 80
  But that gives me the same results (works in simulator, not on device).</p>
  
  <p>Please help me! </p>
  
  <p>I know that the Cordova plugin would be better than the Javascript version, but I don't find the Cordove MQTT plugin for Cordova 3.1. That could help me out to.</p>
  
  <hr>
  
  <pre><code>    var client = new Messaging.Client("192.168.137.2", 8000, "prototype2");
      $(function() {
          $("#publishBtn").click(function() {
              publish("test", "prototype2/testpublish", 1);
          });
  
          var options = {
  
              // connection attempt timeout in seconds
              timeout : 5,
  
              // Gets Called if the connection has successfully been established
              onSuccess : function() {
                  $("#console").append(
                          '&lt;br/&gt;' + "Connected to MQTT Broker over Websockets.");
  
                  // client.subscribe("testtopic", {qos: 2});
                  client.subscribe("prototype3/testpublish");
              },
  
      // Gets Called if the connection could not be established
      onFailure : function(message) {
          $("#console").append(
                  '&lt;br/&gt;' + "Connection failed: " + message.errorMessage);
      }
  };
  // Gets called whenever you receive a message for your subscriptions
  client.onMessageArrived = function(message) {
  
      var topic = message.destinationName;
  
      var message = message.payloadString;
  
      $("#console").append(
              '&lt;br/&gt;' + 'Message arrived: Topic: ' + topic + ', Message: '
                      + message);
  
  };
  
  // Attempt to connect
  client.connect(options);
  </code></pre>
  
  <p>});</p>