Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

coolnameismy
Copy link

我来自阿里云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

我来自阿里云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
@YoDaMa
Copy link
Contributor

YoDaMa commented Feb 26, 2020

Translation:
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

@YoDaMa
Copy link
Contributor

YoDaMa commented Feb 26, 2020

嗨!感谢您的请求请求。您可以删除中文评论吗?还是将它们翻译成英文?抱歉,如果不好,我正在使用Google翻译。 @coolnameismy

@YoDaMa YoDaMa closed this Feb 26, 2020
@YoDaMa YoDaMa reopened this Feb 26, 2020
@coolnameismy
Copy link
Author

嗨!感谢您的请求请求。您可以删除中文评论吗?还是将它们翻译成英文?抱歉,如果不好,我正在使用Google翻译。 @coolnameismy

you translation is accurate, the chinese comment maybe keep for china developer

@YoDaMa
Copy link
Contributor

YoDaMa commented Feb 27, 2020

好的,我也注意到目前没有为这个代码单元编写的测试。你有什么要补充的?最好进行某种形式的测试以演示有效的功能。

@Mickey-
Copy link

Mickey- commented Mar 2, 2020

good job!

@YoDaMa
Copy link
Contributor

YoDaMa commented Mar 13, 2020

@coolnameismy checking back. Tests?

@YoDaMa
Copy link
Contributor

YoDaMa commented Apr 13, 2020

@Mickey- ping ???

@imndx
Copy link

imndx commented May 10, 2020

@coolnameismy 你好,使用了你的patch,但在支付宝小程序里面,提示:FileReader undefined,请问如何处理?

@OmgImAlexis
Copy link
Contributor

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.

@imndx
Copy link

imndx commented May 12, 2020

@coolnameismy 你好,使用了你的patch,但在支付宝小程序里面,提示:FileReader undefined,请问如何处理?

后来测试了下,发现真机没问题,模拟器有问题。

@tennessine
Copy link

@coolnameismy 你好,使用了你的patch,但在支付宝小程序里面,提示:FileReader undefined,请问如何处理?

后来测试了下,发现真机没问题,模拟器有问题。

真机没问题吗?我Android真机也是undefined

@susdevlop
Copy link

susdevlop commented Aug 17, 2020

@coolnameismy @imndx @tennessine 使用了这个patch-1后 包是3.0的版本, 但是真机有机会触发了onConnect事件,但是根本没有推送到信息而且很快就会触发重新执行,是option需要什么别的配置吗

@ghost ghost mentioned this pull request Aug 27, 2020
@wangxiuxiuxiuxiu
Copy link

@coolnameismy @imndx @tennessine 使用了这个patch-1后 包是3.0的版本, 但是真机有机会触发了onConnect事件,但是根本没有推送到信息而且很快就会触发重新执行,是option需要什么别的配置吗

同问,我也触发后马上关闭了,然后重连,你解决了吗?

@tennessine
Copy link

@coolnameismy 你好,使用了你的patch,但在支付宝小程序里面,提示:FileReader undefined,请问如何处理?

后来测试了下,发现真机没问题,模拟器有问题。

真机没问题吗?我Android真机也是undefined

你试试支付宝最新版,肯定是不支持FileReader的,我都试了好几次了

coolnameismy added a commit to coolnameismy/MQTT.js that referenced this pull request Sep 11, 2020
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
@zjalen
Copy link

zjalen commented Mar 31, 2021

@coolnameismy 老哥你好,我最近在开发支付宝小程序时用到 mqtt,采用了你的方案修改源码里参数和 data 转 base64 相关代码,结果在调试时,总出现未知异常,劳烦请教你那边是否正常,有没有可用的 mqtt.js 代码版本?
AppLog 日志如下:
connectSocket

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"
}

sendSocketMessage

Params
{
  "data": "EA==",
  "isBuffer": 1,
  "__appxDomain": "app"
}
Result
{
  "success": true
}
Timing
{
  "start": "16:09:57.87",
  "end": "16:09:57.110",
  "duration": "121ms"
}

sendSocketMessage

Params
{
  "data": "MQ==",
  "isBuffer": 1,
  "__appxDomain": "app"
}
Result
{
  "error": 1,
  "message": "未知错误"
}
Timing
{
  "start": "16:09:57.110",
  "end": "16:09:57.133",
  "duration": "98ms"
}

如上结果反复出现,如有时间烦请指点问题出现在哪里?

@YoDaMa
Copy link
Contributor

YoDaMa commented Mar 2, 2022

closing as we will no longer be adding more transport supports to the current version of the library.

@YoDaMa YoDaMa closed this Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants