MQTT.js
MQTT.js copied to clipboard
fix: fix v4 wechat miniprogram connect error 修复v4版本无法在微信小程序中使用的bug
wechat is exactly run like an browser environment, since we may use subarray to build a typedarray, the buffer underlying is not exactly represents the chunk typedarray we want send.
as the image below, we want send one Byte, but we send 4bytes
the reason is in MQTT-packet, we use subarray
https://github.com/mqttjs/mqtt-packet/blob/7f7c2ed8bcb4b2c582851d120a94e0b4a731f661/numbers.js#L44
and we send the underlying buff
https://github.com/mqttjs/MQTT.js/blob/8b0fa591fbe6575ff855ede104f4d35472546167/lib/connect/wx.js#L12-L17
老哥,你微信小程序使用的哪个版本,4.3.7么? 现在问题解决了么,4.3.7我也遇到不能连接问题:

使用低版本的4.2.1又会有小程序publish 有时候没有callback回调的问题
解决了,用我提交的wx.js即可
快合并吧! 没法用很久了!
没有合并之前,怎么使用?
没合并前,本机编译时,用我提交的wx.js覆盖node_modules/mqtt/lib/connect/wx.js即可
没合并前,本机编译时,用我提交的
wx.js覆盖node_modules/mqtt/lib/connect/wx.js即可 试过了,没有解决,现在报net.createConnection is not a function错误
微信小程序 npm 安装 导入就报错: app.js错误: Error: module 'miniprogram_npm/mqtt/events.js' is not defined, require args is 'events' 或者 VM864:9 app.js错误: ReferenceError: process is not defined