微信小程序使用MQTT报错求解

var Paho = require('../../paho-mqtt');


var client = new Paho.Client('IP地址',端口号, "clientId");


Page({

data:{},

publishMessage: function () {


var message = new Paho.Message('hello world');

message.destinationName = "test/topic"; 

client.send(message);

},

onLoad: function () {


client.onMessageArrived = function (msg) {

  wx.showToast({

    title: msg.payloadString

  });

}

client.onConnectionLost = function (responseObject) {

  if (responseObject.errorCode !== 0) {

    console.log("onConnectionLost:" + responseObject.errorMessage);

  }

}

client.connect({

  useSSL: true,

  cleanSession: false,

  keepAliveInterval: 60,

  userName:123456,

  password:1233456,

  onSuccess: function () {

    console.log('connected');

    client.subscribe("test/topic", {

      qos: 1

    });

  }

});

}

})


现在报错如下:

WebSocket connection to 'wss://IP地址,/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_RESET


www说
浏览 1588回答 1
1回答

慕沐林林

var client = new Paho.Client('IP地址',端口号, "clientId");IP地址 这里改成你的IP端口号 这里改成你的端口
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript