我收到以下错误。
WebSocket与' wss://m12.cloudmqtt.com的连接:39297 / mqtt'失败:>连接建立错误:net :: ERR_CONNECTION_TIMED_OUT
我正在尝试从paho客户端连接到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: "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;
}
当我执行程序功能时,会触发doFail()吗? 可能是什么问题?
答案 0 :(得分:0)
配置防火墙,它运行正常。