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

通过 highway 上传好友图片以提高稳定性 #194

Closed
sandtechnology opened this issue Apr 3, 2020 · 8 comments
Closed

通过 highway 上传好友图片以提高稳定性 #194

sandtechnology opened this issue Apr 3, 2020 · 8 comments
Assignees
Labels
N 优先级: 一般 t:enhancement 类型: 现有功能上的优化 x:protocol 属性: 协议相关
Milestone

Comments

@sandtechnology
Copy link
Collaborator

sandtechnology commented Apr 3, 2020

问题

好友信息中上传的图片失效,上传之后仍然需要上传且无法正常显示,在安卓版QQ上提示图片失效

如何复现

相关代码:
https://github.com/sandtechnology/DantuiHelper/blob/1b03167172e4fb4a8da686a7a1144ab2a5b53d6f/src/main/java/sandtechnology/holder/WriteOnlyMessage.java#L88

public MessageChain toMessageChain(Bot bot, Type type, long id) {
        MessageChainBuilder builder = new MessageChainBuilder();
        for (Pair<String, List<ImageManager.CacheImage>> pair : list) {
            builder.add(pair.getFirst());
            builder.addAll(pair.getLast().stream().map(
                    img-> {
                        if(type == Type.Friend) {
                            return bot.getFriend(id).uploadImage(getExternalImage(img.getFile()));
                        }
                        else {
                            return bot.getGroup(id).uploadImage(getExternalImage(img.getFile()));
                        }
                           }).collect(Collectors.toList()));
                    }
        return builder.asMessageChain();
    }

    private ExternalImage getExternalImage(File file){
        ExternalImage externalImage;
        try {
            externalImage=ExternalImageJvmKt.toExternalImage(file);
        } catch (FileNotFoundException e) {
          return getExternalImage(ImageManager.emptyImage.getFile());
        }catch (Exception e){
            return getExternalImage(file);
        }
        return externalImage;
    }

日志:

[Bot() 13:06:19 : Received: FriendMessage(sender=, message=/fetch 364225566)
[Network() 13:06:19 : Send done: LongConn.OffPicUp
[Network() 13:06:20 : Received: RequireUpload(resourceId=/6a054bce-d528-4494-805a-c50047e54907, serverIp=[995950262, 1827168369, -1547790469, 1593048989], serverPort=[14000, 8080, 80, 443], uKey=[80, -93, -57, 51, -104, -26, -14, -17, 26, -26, 21, -31, -48, 34, 8, -115, 115, 90, -121, -80, -78, 120, -29, 115, 87, -10, -126, -35, -111, 36, -56, -4, 77, 23, -120, -18, -90, -52, 34, 117, -9, -18, 117, -121, -104, 103, -41, -92, 19, -127, 88, 10, -81, 4, 36, -80, -126, -88, -13, 67, 74, 43, -97, 112, -8, -77, 44, -34, -25, 46, 90, -62, 1, -50, 31, 77, 29, 72, 55, -105, 8, 69, 80, 83, -54, -26, -116, 48, 102, 43, -11, -95, -88, -42, 85, -36, 82, -107, -79, -26, 119, -121, -120, -32, -65, -60, -26, -40, 25, 16, -35, -29, -75, 61, -3, -117, -89, 50, -57, -60, -125, -35, 68, -7, -71, 13, 44, 29])
[Network() 13:06:21 : Send done: LongConn.OffPicUp
[Network() 13:06:22 : Received: FileExists(resourceId=/13314e43-23e8-43a9-bf02-9bc9161a4109, imageInfo=net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x352$ImgInfo@d3a31b)
[Network() 13:06:22 : Send done: MessageSvc.PbSendMsg
[Network() 13:06:22 : Received: MessageSvc.PbSendMsg.Response.SUCCESS
[Network() 13:06:22 : Received: MessageSvc.PbGetMsg.GetMsgSuccess(messages=))
[Network() 13:06:34 : Received: net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPushNotify@14adbad
[Network() 13:06:34 : Send: MessageSvc.PbGetMsg
[Bot() 13:06:35 : Received: FriendMessage(sender=, message=/fetch 364225566)
[Network() 13:06:35 : Send done: LongConn.OffPicUp
[Network() 13:06:35 : Received: RequireUpload(resourceId=/2a829200-cf09-4d57-8d67-66ccdc1dc706, serverIp=[995950262, -61266885, -1547790469, 948501050], serverPort=[14000, 8080, 80, 443], uKey=[-50, -24, -75, -60, 87, -32, -55, -30, 22, 71, -101, -57, -56, -40, 31, -22, 126, 8, -56, 124, 126, -102, -16, -51, 124, -85, -78, 60, 20, -77, -82, 34, 125, -42, -91, -29, -42, 69, -85, 100, -67, -116, 41, 83, -86, -59, 102, 112, -101, 79, -41, -60, 36, 54, -66, 29, -27, -99, -118, 109, 80, -110, 68, -67, -78, 12, 67, -65, -8, 62, 87, -101, 17, 18, 52, -4, -105, -48, 44, 116, -53, -110, 21, 73, 32, 41, -25, -105, -86, 118, 70, -123, 47, -109, 25, -90, 72, 0, -63, 20, 4, 125, -54, -4, -61, 84, -112, -122, -31, 48, -124, 118, 15, -23, 14, 54, 58, -9, -67, 43, 127, -20, 34, -82, -16, -114, -107, -31])
[Network() 13:06:37 : Send done: LongConn.OffPicUp
[Network() 13:06:37 : Received: FileExists(resourceId=/bbd83095-00a9-485f-b6b0-ede64df7b13a, imageInfo=net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x352$ImgInfo@178b486)
[Network() 13:06:37 : Send done: MessageSvc.PbSendMsg
[Network() 13:06:37 : Received: MessageSvc.PbSendMsg.Response.SUCCESS
[Network() 13:06:37 : Received: MessageSvc.PbGetMsg.GetMsgSuccess(messages=))
[Network() 13:07:10 : Send done: Heartbeat.Alive
[Network() 13:07:10 : Received: Heartbeat.Alive.Response
[Network() 13:08:10 : Send done: Heartbeat.Alive
[Network() 13:08:10 : Received: Heartbeat.Alive.Response
[Network() 13:10:05 : Send done: Heartbeat.Alive
[Network() 13:10:05 : Received: Heartbeat.Alive.Response
[Network() 13:10:30 : Received: net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPushNotify@1db3907
[Network() 13:10:30 : Send: MessageSvc.PbGetMsg
[Bot() 13:10:31 : Received: FriendMessage(sender=, message=/fetch 364225566)
[Network() 13:10:31 : Send done: LongConn.OffPicUp
[Network() 13:10:31 : Received: RequireUpload(resourceId=/2c367580-f068-42f7-99d8-89ceb857dc3b, serverIp=[1769354105, -1196158450, -1564567685, 948501050], serverPort=[14000, 8080, 80, 443], uKey=[7, 74, 49, -123, -15, 98, 72, -119, 51, -63, 70, 0, -51, 73, -2, 72, -43, 8, 105, -17, -5, 34, -6, -96, -106, -44, 109, 51, 113, 43, 113, 25, -118, -92, 126, -113, -75, 31, -117, -46, 8, 111, 24, -22, 3, -23, -52, -11, -55, 70, 23, -51, 45, 31, 3, 43, 95, 25, 113, -80, 84, -111, -60, 51, -63, -66, 7, 95, 67, -73, -74, -24, -93, -76, 34, -66, -109, 38, 42, -51, 18, 97, 5, 87, -61, 89, 118, 75, -50, -24, 22, 107, -65, -34, -58, 7, -113, 36, 54, 73, -74, -72, 26, -119, 114, 72, 87, 122, 68, 50, -30, 124, -7, -45, -2, 101, 4, -97, 56, 47, 12, -48, -30, 68, 51, -106, 70, 114])
[Network() 13:10:33 : Send done: LongConn.OffPicUp
[Network() 13:10:33 : Received: FileExists(resourceId=/d5e4c74a-942f-40b8-bd04-04921fc72a4c, imageInfo=net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x352$ImgInfo@11cc68c)
[Network() 13:10:33 : Send done: MessageSvc.PbSendMsg
[Network() 13:10:33 : Received: MessageSvc.PbSendMsg.Response.SUCCESS
[Network() 13:10:33 : Received: MessageSvc.PbGetMsg.GetMsgSuccess(messages=))
[Network() 13:11:05 : Send done: Heartbeat.Alive
[Network() 13:11:05 : Received: Heartbeat.Alive.Response

@sandtechnology sandtechnology added the t:bug 类型: bug label Apr 3, 2020
@sandtechnology sandtechnology changed the title [Java] 好友信息中上传的图片失效 好友信息中上传的图片失效 Apr 3, 2020
@Him188
Copy link
Member

Him188 commented Apr 3, 2020

信息不足,无法确认问题。看日志一切正常。
另图片若无法在TIM客户端查看,有可能是客户端问题。

需要提供以下信息:

正在上传的图片原文件
上传这张图片时的日志
官方安卓客户端是否能正常看到图片
图片是第一次上传还是重复上传

@Him188 Him188 added x:question 标签: 需要更多信息 and removed t:bug 类型: bug labels Apr 3, 2020
@sandtechnology
Copy link
Collaborator Author

sandtechnology commented Apr 3, 2020

信息不足,无法确认问题。看日志一切正常。
另图片若无法在TIM客户端查看,有可能是客户端问题。

需要提供以下信息:

正在上传的图片原文件
上传这张图片时的日志
官方安卓客户端是否能正常看到图片
图片是第一次上传还是重复上传

  • 正在上传的图片原文件

https://i0.hdslb.com/bfs/emote/3c210366a5585706c09d4c686a9d942b39feeb50.png@50w_50h_1e_1c.png
(需要直接粘贴到地址栏访问,有referrer检查,本地文件名为3c210366a5585706c09d4c686a9d942b39feeb50.png@50w_50h_1e_1c.png

  • 上传这张图片时的日志

[Bot() 13:58:37 : Received: FriendMessage(sender=1294790523, message=/fetch 10057114)
[Network() 13:58:37 : Send done: LongConn.OffPicUp
[Network() 13:58:37 : Received: RequireUpload(resourceId=/a7086808-5097-4c0d-8f1e-dc22b92b7825, serverIp=[2047540918, 1081680955, -1564567685, 948501050], serverPort=[14000, 8080, 80, 443], uKey=[66, -44, 75, -96, -68, -41, -105, -91, 62, -102, -71, -128, -120, 104, -120, -39, 14, 104, -105, 33, 120, 56, -15, -19, -24, 17, 32, -125, -58, 29, -119, -37, 46, 82, 99, 72, -5, 35, 37, 107, 101, -109, 57, -1, 117, -76, 15, 13, 111, 99, 96, -44, 81, -79, -6, -73, -35, 22, -69, 10, 47, -14, 85, -31, 56, 39, -117, -67, 63, -47, 14, 93, -54, -27, -26, 102, 87, 73, 63, -78, 15, 116, -4, -96, -75, 120, 69, 109, 14, -54, 93, -2, 92, 57, -28, 34, -26, -88, -115, -12, -63, 83, -105, -45, 23, 95, -17, 104, 66, 78, 126, -54, 87, -16, -31, -122, -97, 113, 106, -121, 5, 21, -48, -105, 59, 1, 41, 48])
[Network() 13:58:37 : Send done: MessageSvc.PbSendMsg
[Network() 13:58:38 : Received: MessageSvc.PbSendMsg.Response.SUCCESS
[Network() 13:58:38 : Received: MessageSvc.PbGetMsg.GetMsgSuccess(messages=))

  • 官方安卓客户端能否正常看到图片:

否,提示图片过期

  • 图片是第一次上传还是重复上传

是,图片是第一次上传,且重复上传也如此,且群聊消息正常

@Him188 Him188 added C 优先级: 最高 t:bug 类型: bug and removed x:question 标签: 需要更多信息 labels Apr 4, 2020
@Him188 Him188 self-assigned this Apr 4, 2020
@Him188 Him188 added this to the 0.34.0 milestone Apr 5, 2020
@Him188
Copy link
Member

Him188 commented Apr 6, 2020

image
猜测是上传失败. 因为好友图片走的是 HTTP, 而群图片上传用的是更稳定的一种方式.

@Him188 Him188 added M 优先级: 主要 and removed C 优先级: 最高 labels Apr 6, 2020
@Him188 Him188 changed the title 好友信息中上传的图片失效 通过 highway 上传好友图片以提高稳定性 Apr 6, 2020
@Him188 Him188 modified the milestones: 0.34.0, mirai-core 1.0.0 Apr 6, 2020
@Him188 Him188 added t:enhancement 类型: 现有功能上的优化 and removed t:bug 类型: bug labels Apr 6, 2020
@sandtechnology
Copy link
Collaborator Author

image
猜测是上传失败. 因为好友图片走的是 HTTP, 而群图片上传用的是更稳定的一种方式.

需要通过mirai进行上传时才会有这种情况,而且100%复现,确认是mirai上传的吗?

@Him188
Copy link
Member

Him188 commented Apr 6, 2020

是, 通过 URL 上传的

reply(URL("https://i0.hdslb.com/bfs/emote/3c210366a5585706c09d4c686a9d942b39feeb50.png@50w_50h_1e_1c.png").uploadAsImage())

@sandtechnology
Copy link
Collaborator Author

sandtechnology commented Apr 6, 2020

是, 通过 URL 上传的

reply(URL("https://i0.hdslb.com/bfs/emote/3c210366a5585706c09d4c686a9d942b39feeb50.png@50w_50h_1e_1c.png").uploadAsImage())

那可能真的是连接不稳定吧hhh,我记得如果是重复图片上传的话后台会提示Received: FileExists(resourceId=/xxx)而不会进行上传操作,可以试试改下50w_50h,设置成其他尺寸的照片看看,比如25w_25h

@Him188 Him188 added the x:protocol 属性: 协议相关 label Apr 7, 2020
@Him188
Copy link
Member

Him188 commented Apr 24, 2020

做不成, 算了.
HTTP也不是不能跑

@Him188 Him188 removed this from the mirai-core 1.0.0 milestone Apr 24, 2020
@Him188 Him188 removed the M 优先级: 主要 label Apr 24, 2020
@Him188 Him188 removed their assignment Apr 25, 2020
@Him188 Him188 added this to the 2.0.0 milestone Jul 16, 2020
@Him188 Him188 removed this from the 2.0.0 milestone Aug 22, 2020
@Him188 Him188 added this to the 2.1.0 milestone Aug 22, 2020
@Him188 Him188 modified the milestones: 2.1.0, 2.2.0 Jan 12, 2021
Him188 added a commit that referenced this issue Jan 22, 2021
@Him188 Him188 mentioned this issue Jan 26, 2021
@Him188 Him188 added the N 优先级: 一般 label Jan 26, 2021
@Him188 Him188 self-assigned this Jan 26, 2021
Him188 added a commit that referenced this issue Jan 26, 2021
Add fallback strategies for uploading group voice #577 and private image #916
@Him188
Copy link
Member

Him188 commented Jan 26, 2021

2.2.0-dev-bdh-2

@Him188 Him188 closed this as completed in d8b1505 Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 t:enhancement 类型: 现有功能上的优化 x:protocol 属性: 协议相关
Projects
None yet
Development

No branches or pull requests

2 participants