0
我收到以下错误。MQTT WebSocket连接在CloudMQTT中失败
WebSocket连接到 'WSS://m12.cloudmqtt.com:39297/MQTT' 失败:错误>连接设置:网:: ERR_CONNECTION_TIMED_OUT
我试图连接到从cloudmqtt帕霍客户。
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: "[email protected]",
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;
}
当我执行程序函数doFail()被触发? 可能是什么问题?