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 ?
配置了防火墙,它可以正常工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.