0

I am getting the following error.

WebSocket connection to 'wss://m12.cloudmqtt.com:39297/mqtt' failed: Error in >connection establishment: net::ERR_CONNECTION_TIMED_OUT

I am trying to connect to cloudmqtt from paho client.

    client = new Paho.MQTT.Client("m12.cloudmqtt.com", Number(39297),    "client_1");
    // set callback handlers
    client.onConnectionLost = onConnectionLost;
    client.onMessageArrived = onMessageArrived;

    // connect the client
    var options = {
            useSSL: true,
            userName: "wRRDCvty@q",
            password: "lM#$Ffg67OR",
            cleanSession: true,
            onSuccess:onConnect,
            onFailure:doFail
          }

    //client.connect({onSuccess:onConnect});
    client.connect(options);

    // called when the client connects
    function onConnect() {
      // Once a connection has been made, make a subscription and send a       message.
     debugger;
        console.log("onConnect");
      client.subscribe("outTopic");
      message = new Paho.MQTT.Message("Hello");
      message.destinationName = "World";
      client.send(message);
    }

    function doFail(){
        debugger;
        console.log("dofail");
    }
    // called when the client loses its connection
    function onConnectionLost(responseObject) {
      if (responseObject.errorCode !== 0) {
        console.log("onConnectionLost:"+responseObject.errorMessage);
      }
    }

    // called when a message arrives
    function onMessageArrived(message) {
      console.log("onMessageArrived:"+message.payloadString);
      var msg = message.payloadString;
      debugger;

    }

When i execute the program function doFail() is triggered? What might be the problem ?

Deepan
  • 41
  • 1
  • 2
  • 8

1 Answers1

0

Configured the firewall and it works fine.

Deepan
  • 41
  • 1
  • 2
  • 8