Open VermiIIi0n opened 1 year ago
我这边也有这个错误,好久了都没修复
我看了下源码这是因为在MiraiGo中,调用腾讯ttl接口后,从response中读取bytes的时候出错了,MiraiGo用了一个自建的buffer reader,然后逐个读取bytes的内容直到遇到0x0d
,也就是ASCII的 \r 换行符
这是他的 ReadByte 代码:
func (r *Reader) ReadByte() byte {
b, err := r.buf.ReadByte()
if err != nil {
panic(err)
}
return b
}
这里底层实际调用了 bytes.Reader.ReadByte()
这是它的源码:
// ReadByte implements the io.ByteReader interface.
func (r *Reader) ReadByte() (byte, error) {
r.prevRune = -1
if r.i >= int64(len(r.s)) {
return 0, io.EOF // <--- 在这里,当读取到超出长度的时候(也就是读到结束),会返回一个结束符error
}
b := r.s[r.i]
r.i++
return b, nil
}
那么很显然就是没有读取到\r换行符直接读到response的结尾引发了异常。我并不太清楚腾讯在tts的接口上返回的具体数据格式。 看起来可能是某些意外情况,接受的二进制不完整或者怎么样,但我觉得可以用warning的日志输出,没必要用panic去输出错误栈
请确保您已阅读以上注意事项,并勾选下方的确认框。
go-cqhttp 版本
1.0.0-rc5
运行环境
MacOS
运行架构
ARM [64] (别名:AArch64 / ARMv8)
连接方式
WebSocket (正向)
使用协议
6 | Android Pad
重现步骤
发送 WS 请求:
在日志报错:
Log
```shell [2023-03-27 18:55:30] [ERROR]: 处置WS命令时发生无法恢复的异常:EOF goroutine 59445 [running]: runtime/debug.Stack() runtime/debug/stack.go:24 +0x64 github.com/Mrs4s/go-cqhttp/server.(*wsConn).handleRequest.func1() github.com/Mrs4s/go-cqhttp/server/websocket.go:471 +0x3c panic({0x101290f20, 0x1400008e060}) runtime/panic.go:884 +0x1f4 github.com/Mrs4s/MiraiGo/binary.(*Reader).ReadByte(...) github.com/Mrs4s/MiraiGo@v0.0.0-20230317162854-fd83d24f6794/binary/reader.go:32 github.com/Mrs4s/MiraiGo/client.(*QQClient).GetTts(0x14000644000, {0x140004ac063, 0x7}) github.com/Mrs4s/MiraiGo@v0.0.0-20230317162854-fd83d24f6794/client/http_api.go:92 +0x720 github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).ConvertElement(0x1400046e000, 0x1016db860, {{0x140004ac04e, 0x3}, {0x1400007a0a0, 0x1, 0x1}}, 0x2) github.com/Mrs4s/go-cqhttp/coolq/cqcode.go:658 +0x3ff8 github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).ConvertElements(0x5?, 0x140004ac044?, {0x14000694390?, 0x1, 0x0?}, 0x0?) github.com/Mrs4s/go-cqhttp/coolq/cqcode.go:417 +0xd4 github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).ConvertObjectMessage(0x0?, 0x1016db860, {0x5, {0x140004ac044, 0x2a}, {0x0, 0x0}, 0x0, 0x44, {0x0, ...}}, ...) github.com/Mrs4s/go-cqhttp/coolq/cqcode.go:396 +0xc8 github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).CQSendGroupMessage(0x1400046e000, 0x12dacfe9, {0x5, {0x140004ac044, 0x2a}, {0x0, 0x0}, 0x0, 0x44, {0x0, ...}}, ...) github.com/Mrs4s/go-cqhttp/coolq/api.go:757 +0xe4 github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).call(0x14000374760, {0x140004ac00b, 0xe}, 0x1016db860, {0x10135aeb8, 0x1400045e410}) github.com/Mrs4s/go-cqhttp/modules/api/api.go:43 +0xa6c github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).Call(0x14000374760, {0x140004ac00b, 0xe}, 0x0?, {0x10135aeb8, 0x1400045e410}) github.com/Mrs4s/go-cqhttp/modules/api/caller.go:35 +0xb0 github.com/Mrs4s/go-cqhttp/server.(*wsConn).handleRequest(0x140000a8768, 0x1400046e000?, {0x140004ac000?, 0x7b?, 0x300?}) github.com/Mrs4s/go-cqhttp/server/websocket.go:480 +0x2c4 github.com/Mrs4s/go-cqhttp/server.(*webSocketServer).listenAPI.func2(0x14000754330?) github.com/Mrs4s/go-cqhttp/server/websocket.go:460 +0x88 created by github.com/Mrs4s/go-cqhttp/server.(*webSocketServer).listenAPI github.com/Mrs4s/go-cqhttp/server/websocket.go:458 +0x144 ```期望的结果是什么?
正常发送 TTS 消息, 或者正常回报错误.
实际的结果是什么?
WS 连接因错误中断.
简单的复现代码/链接(可选)
No response
日志记录(可选)
No response
补充说明(可选)
No response