Open fatesinger opened 5 years ago
please try with v0.0.58
更新到 v0.0.58 还是不行。
需要提供详细log,不仅是报错部分的,需要上下文
之前的报错是 捕获 message.toFileBox() 异常 报的错。silly 日志没有报错
@fatesinger 你能找到这个问题的复现方法么?
关于这个报错,大概是什么类型的文件会报错?是不是文件名是中文名?文件是通过什么客户端发送的?
wechaty 版本:0.27.59
wechaty-puppet-padpro 版本:0.3.12
node 版本: v10.13.0
你使用的操作系统:ubuntu
通过 pc 端微信给 bot 发送文件
bot 收到消息后调用 message.toFileBox()
方法
查看手机微信消息,点击发送的文件(iphone)
如果文件提示需要下载,这个文件肯定会获取失败
如图
会失败的文件
成功的文件
代码报错位置
wechaty-puppet-padpro/src/manager/cdn-manager.ts
private async _sendCdnRequest (
data: Buffer,
url: string,
): Promise<Buffer> {
log.silly(PRE, `sendCdnRequest(${url})`)
if (!this.cdnInfo) {
throw new Error(`Can not send cdn request to cdn server since there is no cdn info yet.`)
}
...
return new Promise<Buffer>((resolve, reject) => {
const req: ClientRequest = http.request(options, async (response: IncomingMessage) => {
const rawData: any = []
let dataLen = 0
if (response.statusCode !== 200) {
// 这里会报错
// response.statusCode 400
// response.statusMessage 400 Bad Request
reject(new Error(`sendCdnRequest failed, status code: ${response.statusCode}, status message: ${response.statusMessage}`))
}
...
})
req.setTimeout(SEND_SHORT_TIMEOUT)
req.on('error', (error: Error) => {
console.error(error)
reject(error)
})
req.on('timeout', () => {
req.abort()
reject(new Error(`TIMEOUT`))
})
req.write(data)
req.end()
})
}
总结: ios没有自动下载的文件,调用 message.toFileBox()
方法就会失败,请求下载时cdn地址报错400,猜测可能大文件的下载方式不同,组包信息可能有变化。
Thanks for the very detailed issue, we will look into this issue later.
0. 发 Issue 指南
请运行下面的命令,看问题是否可以被解决:
请在 FAQ 清单 看是否已有解决办法。
请先在issue 中搜关键信息,确认你要发的内容和之前的issue 不重复。
1. 提供你的包版本信息
2. Bug 描述
个别文件获取失败
3. 复现的步骤 (或者解决的步骤)
给bot发送文件,通过 toFileBox 获取失败
例子:
4. 期待程序运行的结果
正确获取到文件
5. 程序实际运行的结果
报错,大致是解密出错
6. 完整的日志信息:
silly 日志
```shell 18:55:49 VERB Puppet messagePayload(1002093824) 获取文件失败 Error: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length at Decipheriv.final (internal/crypto/cipher.js:164:28) at Object.exports.decryptAes (/node_modules/wechaty-puppet-padpro/dist/src/utils/aes-utils.js:18:41) at CDNManager.7. 其他信息
不能正确获取的文件
导入项目测试.xlsx