qqlight-websocket icon indicating copy to clipboard operation
qqlight-websocket copied to clipboard

发送较大图片会让websocket连接中断

Open AiKoSoSuBeTe opened this issue 4 years ago • 1 comments

我尝试着做一个QQ跑团游戏,利用JS canvas导入背景地图后,在上面描绘人物所在位置的点。背景图37KB,描绘后将Base64转为16进制数据,利用method: "uploadImage"接口发送的时候,会导致与QQLight的连接中断(这时的JSON data项有590KB大)。使用较小背景图(5KB)测试后能够正常发送,所以考虑是图片大小的原因 日志 08-27 09:32:05 WebSocket Protocol receiveConnect Accepted client: 1.0.0.0:10606 08-27 09:32:05 WebSocket Protocol wsShakeHands WebSocket handshake succeeded 08-27 09:32:10 QQLight [接收]-群消息 群:511371420 QQ:1097793260 。pic 70 50 08-27 09:32:10 WebSocket Protocol wsClientDataHandle This is not the final fragment in a message 08-27 09:32:10 WebSocket Protocol removeClient Client socket closed, now length of clients: 0

AiKoSoSuBeTe avatar Aug 27 '19 01:08 AiKoSoSuBeTe

当时考虑到WebSocket单帧就能容纳很大数据,就偷懒没去做多帧的处理。但是有些库的确会把数据拆分,即使数据是一个帧是可以装下的。 不过最近估计没时间修这些库了,建议你尝试下换一个库,或者先将图片上传到服务器利用pic=url代替pic=guid。pic=图片路径发图应该也是可行的,这个我没尝试过

chocolatl avatar Aug 27 '19 04:08 chocolatl