MQTT.js icon indicating copy to clipboard operation
MQTT.js copied to clipboard

fix: fix v4 wechat miniprogram connect error 修复v4版本无法在微信小程序中使用的bug

Open shushenghong opened this issue 2 years ago • 2 comments

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

image image

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

shushenghong avatar Jul 09 '22 01:07 shushenghong

老哥,你微信小程序使用的哪个版本,4.3.7么? 现在问题解决了么,4.3.7我也遇到不能连接问题: image

使用低版本的4.2.1又会有小程序publish 有时候没有callback回调的问题

wanggaian avatar Sep 11 '22 09:09 wanggaian

解决了,用我提交的wx.js即可

shushenghong avatar Sep 12 '22 00:09 shushenghong

快合并吧! 没法用很久了!

blusewang avatar Jan 31 '23 04:01 blusewang

没有合并之前,怎么使用?

blusewang avatar Jan 31 '23 04:01 blusewang

没合并前,本机编译时,用我提交的wx.js覆盖node_modules/mqtt/lib/connect/wx.js即可

shushenghong avatar Jan 31 '23 06:01 shushenghong

没合并前,本机编译时,用我提交的wx.js覆盖node_modules/mqtt/lib/connect/wx.js即可 试过了,没有解决,现在报net.createConnection is not a function错误

bigtian99 avatar Mar 29 '23 03:03 bigtian99

微信小程序 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

dong-lufei avatar Apr 27 '23 07:04 dong-lufei