为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

www说 2019-02-27 09:23:14
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
查看完整描述

1 回答

?
慕沐林林

TA贡献2016条经验 获得超9个赞

var client = new Paho.Client('IP地址',端口号, "clientId");
IP地址 这里改成你的IP
端口号 这里改成你的端口

查看完整回答
反对 回复 2019-03-06
  • 1 回答
  • 0 关注
  • 1587 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号