-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
订正mqttjs使用支付宝小程序mqtt连接时出错 #1057
Conversation
我来自阿里云IoT事业部,提供jssdk给开发者用于连接阿里云物联网平台(https://github.com/aliyun/alibabacloud-iot-device-sdk),最近发现阿里小程序的用户无法正常使用,定位到原因是因为mqttjs使用了支付宝api不规范导致(这个问题是和支付宝小程序容器开发同学蕴峰一起定位)所以提出正确的修改方式如下: 订正mqttjs使用支付宝小程序mqtt连接时出错 1:my.connectSocket 传入protocols会被拦截,需要增加headers参数 2:sendSocketMessage data 需要为base64 string ,并且需要isBuffer:1
Translation: Correct mqttjs error when using Alipay applet mqtt connection |
嗨!感谢您的请求请求。您可以删除中文评论吗?还是将它们翻译成英文?抱歉,如果不好,我正在使用Google翻译。 @coolnameismy |
you translation is accurate, the chinese comment maybe keep for china developer |
好的,我也注意到目前没有为这个代码单元编写的测试。你有什么要补充的?最好进行某种形式的测试以演示有效的功能。 |
good job! |
@coolnameismy checking back. Tests? |
@Mickey- ping ??? |
@coolnameismy 你好,使用了你的patch,但在支付宝小程序里面,提示:FileReader undefined,请问如何处理? |
Can we please have English comments left in the code as they're a lot easier on Google translate for other language developers than Chinese tends to be. |
后来测试了下,发现真机没问题,模拟器有问题。 |
真机没问题吗?我Android真机也是undefined |
@coolnameismy @imndx @tennessine 使用了这个patch-1后 包是3.0的版本, 但是真机有机会触发了onConnect事件,但是根本没有推送到信息而且很快就会触发重新执行,是option需要什么别的配置吗 |
同问,我也触发后马上关闭了,然后重连,你解决了吗? |
你试试支付宝最新版,肯定是不支持FileReader的,我都试了好几次了 |
I am from Alibaba Cloud IoT Business Unit. I provide jssdk for developers to connect to the Alibaba Cloud IoT platform (https://github.com/aliyun/alibabacloud-iot-device-sdk). I recently found that the users of Alibaba Applet cannot work normally The reason for using it is that mqttjs uses Alipay APIs that are not standardized (this problem is located with Yunfeng, a classmate of Alipay applet container development), so the correct modification is proposed as follows: Correct mqttjs error when using Alipay applet mqtt connection 1: my.connectSocket incoming protocol will be intercepted, you need to increase the headers parameter 2: sendSocketMessage data needs to be a base64 string, and isBuffer: 1 is required issue : mqttjs#1057
@coolnameismy 老哥你好,我最近在开发支付宝小程序时用到 mqtt,采用了你的方案修改源码里参数和 data 转 base64 相关代码,结果在调试时,总出现未知异常,劳烦请教你那边是否正常,有没有可用的 mqtt.js 代码版本? Params
{
"url": "wss://example****/mqtt",
"headers": {
"Sec-WebSocket-Protocol": "mqtt"
},
"__appxDomain": "app"
}
Result
{
"success": true
}
Timing
{
"start": "16:09:56.918",
"end": "16:09:57.60",
"duration": "289ms"
}
Params
{
"data": "EA==",
"isBuffer": 1,
"__appxDomain": "app"
}
Result
{
"success": true
}
Timing
{
"start": "16:09:57.87",
"end": "16:09:57.110",
"duration": "121ms"
}
Params
{
"data": "MQ==",
"isBuffer": 1,
"__appxDomain": "app"
}
Result
{
"error": 1,
"message": "未知错误"
}
Timing
{
"start": "16:09:57.110",
"end": "16:09:57.133",
"duration": "98ms"
} 如上结果反复出现,如有时间烦请指点问题出现在哪里? |
closing as we will no longer be adding more transport supports to the current version of the library. |
我来自阿里云IoT事业部,提供jssdk给开发者用于连接阿里云物联网平台(https://github.com/aliyun/alibabacloud-iot-device-sdk),最近发现阿里小程序的用户无法正常使用,定位到原因是因为mqttjs使用了支付宝api不规范导致(这个问题是和支付宝小程序容器开发同学蕴峰一起定位)所以提出正确的修改方式如下:
订正mqttjs使用支付宝小程序mqtt连接时出错
1:my.connectSocket 传入protocols会被拦截,需要增加headers参数
2:sendSocketMessage data 需要为base64 string ,并且需要isBuffer:1