1***@qq.com
1***@qq.com
  • 发布:2023-06-27 09:34
  • 更新:2023-06-27 09:34
  • 阅读:113

【报Bug】mqtt3.0在微信小程序中无限重连

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10专业版 1607

HBuilderX类型: Alpha

HBuilderX版本号: 3.8.6

第三方开发者工具版本号: 3.8.6.20230621-alpha

基础库版本号: 2.32.3

项目创建方式: HBuilderX

示例代码:

async connect() {
var self = this
self.logs.push('connect')
// #ifdef H5
var client = mqtt.connect('ws://test.mosquitto.org:8080')
// #endif
// #ifdef MP-WEIXIN||APP-PLUS
var client = mqtt.connect('wx://test.mosquitto.org:8080')
// #endif
client.on('connect', function() {
self.logs.push('on connect')
client.subscribe('presence', function(err) {
if (!err) {
client.publish('presence', 'hello mqtt')
}
})
}).on('reconnect', function() {
self.logs.push('on reconnect')
}).on('error', function() {
self.logs.push('on error')
}).on('end', function() {
self.logs.push('on end')
}).on('message', function(topic, message) {
console.log(message)
self.logs.push(message.toString())
})
}

操作步骤:

运行到微信小程序后点击connect按钮,进行连接mqtt

预期结果:

页面上依次输出connect,on connect,hello mqtt

实际结果:

在手机上无法连接mqtt,页面上输出connect 一段时间后输出on reconnect。在微信开发者工具正常显示

bug描述:

在微信开发者工具中可以正常连接mqtt,预览或真机调试后,手机上无法连接mqtt,并且无限重连

2023-06-27 09:34 负责人:无 分享
已邀请:

要回复问题请先登录注册