mamoe / mirai

高效率 QQ 机器人支持库
https://mirai.mamoe.net
GNU Affero General Public License v3.0
14.5k stars 2.55k forks source link

发送消息上传本地图片出现图片不完整 #2539

Closed MR-XieXuan closed 1 year ago

MR-XieXuan commented 1 year ago

问题描述

上传图片出现图片不完整 发送图片效果: image 原图: ivA1s67PG7sX564rD258

复现

网络质量差 高负载 使用mirai-api-http使用sendGroupMessage发送消息时附带本地图片

mirai-core 版本

2.14.0

bot-protocol

ANDROID_WATCH

其他组件版本

mirai-api-http

系统日志

No response

网络日志

2023-02-28 14:03:09 V/: [Highway] Uploading group image to 106.55.124.176:14000, size=63.97 KiB
2023-02-28 14:03:10 V/: [Highway] Uploading group image: succeed at 75 KiB/s

补充信息

2023-02-28 14:04:43 E/MAH Access: java.lang.IllegalArgumentException: Unsupported image type (mirai) for ExternalResource net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@540f60ad, considering use gif/png/bmp/jpg format. image header:  java.lang.IllegalArgumentException: Unsupported image type (mirai) for ExternalResource net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@540f60ad, considering use gif/png/bmp/jpg format. image header:  at net.mamoe.mirai.internal.message.image.ImageDecoderKt.calculateImageInfo(ImageDecoder.kt:159) at net.mamoe.mirai.internal.contact.CommonGroupImpl$uploadImage$lambda-16$$inlined$runBIO$1.invoke(CoroutineUtils.kt:23) at kotlinx.coroutines.InterruptibleKt.runInterruptibleInExpectedContext(Interruptible.kt:51) at kotlinx.coroutines.InterruptibleKt.access$runInterruptibleInExpectedContext(Interruptible.kt:1) at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invokeSuspend(Interruptible.kt:43) at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invoke(Interruptible.kt) at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invoke(Interruptible.kt) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source) at kotlinx.coroutines.InterruptibleKt.runInterruptible(Interruptible.kt:42) at net.mamoe.mirai.internal.contact.CommonGroupImpl.uploadImage$suspendImpl(GroupImpl.kt:454) at net.mamoe.mirai.internal.contact.CommonGroupImpl.uploadImage(GroupImpl.kt) at net.mamoe.mirai.utils.ExternalResource$Companion.uploadAsImage(ExternalResource.kt:434) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.internal.convertor.ConvertorKt.imageLikeToMessage(convertor.kt:125) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.internal.convertor.ConvertorKt.toMessage(convertor.kt:74) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.internal.convertor.ConvertorKt.toMessageChain(convertor.kt:57) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.internal.action.MessageKt.onSendGroupMessage(message.kt:126) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.router.MessageKt$messageRouter$1$invoke$$inlined$respondDTOStrategy$3.invokeSuspend(dsl.kt:198) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.router.MessageKt$messageRouter$1$invoke$$inlined$respondDTOStrategy$3.invoke(dsl.kt) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.router.MessageKt$messageRouter$1$invoke$$inlined$respondDTOStrategy$3.invoke(dsl.kt) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.router.MessageKt$messageRouter$1$invoke$$inlined$httpAuthedPost$2$1.invokeSuspend(dsl.kt:207) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.router.MessageKt$messageRouter$1$invoke$$inlined$httpAuthedPost$2$1.invoke(dsl.kt) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.router.MessageKt$messageRouter$1$invoke$$inlined$httpAuthedPost$2$1.invoke(dsl.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Route$buildPipeline$1$1.invokeSuspend(Route.kt:116) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invokeSuspend(Pipeline.kt:478) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing.executeResult(Routing.kt:174) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing.interceptor(Routing.kt:49) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing$Plugin$install$1.invokeSuspend(Routing.kt:124) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.auth.Authorization$install$1.invokeSuspend(Authorization.kt:41) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.auth.Authorization$install$1.invoke(Authorization.kt) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.auth.Authorization$install$1.invoke(Authorization.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invokeSuspend(BaseApplicationEngine.kt:122) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.handler.HttpRouterAccessHandler.intercept(HttpRouterAccessHandler.kt:35) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.handler.HttpRouterAccessHandler.access$intercept(HttpRouterAccessHandler.kt:24) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.handler.HttpRouterAccessHandler$Feature$install$1.invokeSuspend(HttpRouterAccessHandler.kt:90) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.handler.HttpRouterAccessHandler$Feature$install$1.invoke(HttpRouterAccessHandler.kt) at mirai-api-http-2.8.0.mirai2.jar//net.mamoe.mirai.api.http.adapter.http.feature.handler.HttpRouterAccessHandler$Feature$install$1.invoke(HttpRouterAccessHandler.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invokeSuspend(DefaultEnginePipeline.kt:118) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17) at mirai-api-http-2.8.0.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2.invokeSuspend(CIOApplicationEngine.kt:189) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) 

MR-XieXuan commented 1 year ago

有时甚至会出现图片混乱的问题, 原图: image 实际发送效果: 5U{3 00KXALUKJ%F572 Bot上一条发送的图片为 DM69$UR50`R0UYK(0G`W4FH 在这里出现了发送图片携带上一条消息图片元素的问题。

cssxsh commented 1 year ago

@ryoii

cssxsh commented 1 year ago

mirai-api-http 的问题为什么不汇报到 https://github.com/project-mirai/mirai-api-http

MR-XieXuan commented 1 year ago

mirai-api-http 的问题为什么不汇报到 https://github.com/project-mirai/mirai-api-http

因为我没有判断出这个是 mirai-api-http 的问题还是 mirai 的问题 :kissing:

ryoii commented 1 year ago

看不出哪里有问题,你自己的代码是怎么写的,是不是重复把内容输出到同一个文件了

MR-XieXuan commented 1 year ago

看不出哪里有问题,你自己的代码是怎么写的,是不是重复把内容输出到同一个文件了

我查了本地文件,本地文件是正常的。只有发送出去后出现了异常。

MR-XieXuan commented 1 year ago

看不出哪里有问题,你自己的代码是怎么写的,是不是重复把内容输出到同一个文件了

是否需要获取其他地方的日志以进一步定位问题出现按的原因。

ryoii commented 1 year ago

是不是重复把内容输出到同一个文件了

MR-XieXuan commented 1 year ago

是不是重复把内容输出到同一个文件了

并没有

MR-XieXuan commented 1 year ago

image 我查了s'yo所有的文件,都没有出错

ryoii commented 1 year ago

mah 通过传入的 path 调用 File.uploadAsImage. core 判断一下是不是上传的时候内部 buffer 了什么东西

Karlatemp commented 1 year ago

为什么会出现header都没读取到的情况呢?你是没等图片输出完毕再执行发送的吗?还是你的系统有高并发的错误呢

MR-XieXuan commented 1 year ago

为什么会出现header都没读取到的情况呢?你是没等图片输出完毕再执行发送的吗?还是你的系统有高并发的错误呢

图片是输出完了才发送的。 操作系统是 Alma 8.5 (Arctic Sphynx) x86_64 。

Karlatemp commented 1 year ago

我还是认为是你的系统 / 架构有问题,不然这没法解释为什么会出现读取不到 header (数据内容) 的错误

cssxsh commented 1 year ago

我还是认为是你的系统 / 架构有问题,不然这没法解释为什么会出现读取不到 header (数据内容) 的错误

我觉得是它异步写入没有堵塞等待的原因

MR-XieXuan commented 1 year ago

我还是认为是你的系统 / 架构有问题,不然这没法解释为什么会出现读取不到 header (数据内容) 的错误

确实,这也让我很迷茫