已解决 上传,发送图片抛出异常?
-
不太清楚是什么原因导致的。
2021-07-03 20:42:58 E/main: Exception in coroutine <unnamed> net.mamoe.mirai.event.ExceptionInEventHandlerException: Exception in EventHandler at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$14$1.invoke(JvmMethodListenersInternal.kt:147) at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$14$2.invokeSuspend(JvmMethodListenersInternal.kt:154) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$14$1.invoke(JvmMethodListenersInternal.kt:140) ... 7 more Caused by: java.lang.IllegalStateException: para error at net.mamoe.mirai.internal.contact.AbstractUser.uploadImage$suspendImpl(AbstractUser.kt:193) at net.mamoe.mirai.internal.contact.AbstractUser$uploadImage$1.invokeSuspend(AbstractUser.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:113) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178) at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166) at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:362) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:396) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:388) at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:293) at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1408) at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:318) at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:295) at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:853) at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core(JobSupport.kt:803) at kotlinx.coroutines.CompletableDeferredImpl.complete(CompletableDeferred.kt:92) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler$PacketListener.complete(QQAndroidBotNetworkHandler.kt) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler.handlePacket(QQAndroidBotNetworkHandler.kt:635) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler$generifiedParsePacket$2.invokeSuspend(QQAndroidBotNetworkHandler.kt:603) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler$generifiedParsePacket$2.invoke(QQAndroidBotNetworkHandler.kt) at net.mamoe.mirai.internal.network.protocol.packet.KnownPacketFactories.handleIncomingPacket$mirai_core(PacketFactory.kt:284) at net.mamoe.mirai.internal.network.protocol.packet.KnownPacketFactories.parseIncomingPacket(PacketFactory.kt:246) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler.generifiedParsePacket(QQAndroidBotNetworkHandler.kt:594) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler.parsePacket(QQAndroidBotNetworkHandler.kt:589) at net.mamoe.mirai.internal.network.handler.QQAndroidBotNetworkHandler$parsePacketAsync$1.invokeSuspend(QQAndroidBotNetworkHandler.kt:571) ... 6 more >
上传图片的部分代码:
ExternalResource.Companion.uploadAsImage(externalResource, event.getSubject());
我尝试使用sendAsImage方法时会抛出相同错误,不知道原因如何,求教。
-
-
ExternalResource 记得要close
-
@nambers 更新了版本后解决了问题,然后出现了新的问题……
-
@karlatemp 在 上传,发送图片抛出异常? 中说:
于是更新版本后就变成了400错误,梯子也关了,但是依然不行。
2021-07-03 21:13:04 E/main: Exception in coroutine <unnamed> net.mamoe.mirai.event.ExceptionInEventHandlerException: Exception in EventHandler at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$14$1.invoke(JvmMethodListenersInternal.kt:147) at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$14$2.invokeSuspend(JvmMethodListenersInternal.kt:154) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$14$1.invoke(JvmMethodListenersInternal.kt:140) ... 7 more Caused by: io.ktor.client.features.ClientRequestException: Client request(http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0070&uin=2687717861&term=pc&ver=5603&filesize=1815167&range=0&ukey=**********************************************) invalid: 404 Not Found. Text: "" at io.ktor.client.features.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invokeSuspend(DefaultResponseValidation.kt:39) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at io.ktor.utils.io.internal.CancellableReusableContinuation.resumeWith(CancellableReusableContinuation.kt:93) at io.ktor.utils.io.ByteBufferChannel.resumeReadOp(ByteBufferChannel.kt:2151) at io.ktor.utils.io.ByteBufferChannel.tryTerminate$ktor_io(ByteBufferChannel.kt:408) at io.ktor.utils.io.ByteBufferChannel.close(ByteBufferChannel.kt:155) at io.ktor.utils.io.CoroutinesKt$launchChannel$1.invoke(Coroutines.kt:143) at io.ktor.utils.io.CoroutinesKt$launchChannel$1.invoke(Coroutines.kt) at kotlinx.coroutines.InvokeOnCompletion.invoke(JobSupport.kt:1385) at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1520) at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:323) at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:240) at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:903) at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:860) at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:825) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) ... 5 more Suppressed: java.lang.IllegalStateException: cannot upload private image, failed on all servers. at net.mamoe.mirai.internal.contact.AbstractUser.uploadImage$suspendImpl(AbstractUser.kt:251) at net.mamoe.mirai.internal.contact.AbstractUser$uploadImage$1.invokeSuspend(AbstractUser.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:113) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:191) at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(SuspendFunctionGun.kt:15) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:86) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:191) at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(SuspendFunctionGun.kt:15) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:86) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:191) at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(SuspendFunctionGun.kt:15) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:86) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:188) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:144) at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:15) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:90) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178) at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166) at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:362) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:396) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:388) at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:293) at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1408) ... 13 more Suppressed: java.lang.IllegalStateException: cannot upload private image, failed on all servers. at net.mamoe.mirai.internal.network.highway.Highway.uploadResourceBdh(Highway.kt:452) at net.mamoe.mirai.internal.network.highway.Highway$uploadResourceBdh$1.invokeSuspend(Highway.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:113) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:266) at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith$default(DispatchedContinuation.kt:263) at kotlinx.coroutines.internal.ScopeCoroutine.afterCompletion(Scopes.kt:27) at kotlinx.coroutines.JobSupport.continueCompleting(JobSupport.kt:933) at kotlinx.coroutines.JobSupport.access$continueCompleting(JobSupport.kt:28) at kotlinx.coroutines.JobSupport$ChildCompletion.invoke(JobSupport.kt:1152) ... 13 more Suppressed: java.lang.IllegalStateException: cannot upload private image, failed on all servers. ... 25 more Suppressed: java.lang.IllegalStateException: cannot upload private image, failed on all servers. ... 25 more Caused by: java.lang.IllegalStateException: highway transfer failed, error 82 at net.mamoe.mirai.internal.network.highway.HighwayKt.sendReceiveHighway(Highway.kt:360) at net.mamoe.mirai.internal.network.highway.HighwayKt$sendReceiveHighway$1.invokeSuspend(Highway.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ... 5 more Caused by: java.lang.IllegalStateException: highway transfer failed, error 83 at net.mamoe.mirai.internal.network.highway.HighwayKt.sendReceiveHighway(Highway.kt:360) at net.mamoe.mirai.internal.network.highway.HighwayKt$sendReceiveHighway$1.invokeSuspend(Highway.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ... 5 more Suppressed: java.lang.IllegalStateException: highway transfer failed, error 83 ... 8 more Suppressed: java.lang.IllegalStateException: highway transfer failed, error 83 ... 8 more Suppressed: java.lang.IllegalStateException: highway transfer failed, error 83 ... 8 more Caused by: java.lang.IllegalStateException: highway transfer failed, error 82 at net.mamoe.mirai.internal.network.highway.HighwayKt.sendReceiveHighway(Highway.kt:360) at net.mamoe.mirai.internal.network.highway.HighwayKt$sendReceiveHighway$1.invokeSuspend(Highway.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ... 5 more Suppressed: java.lang.IllegalStateException: highway transfer failed, error 82 ... 8 more Suppressed: java.lang.IllegalStateException: highway transfer failed, error 82 ... 8 more Suppressed: java.lang.IllegalStateException: highway transfer failed, error 82 ... 8 more Caused by: io.ktor.client.features.ClientRequestException: Client request(http://180.97.117.144:443/cgi-bin/httpconn?htcmd=0x6ff0070&uin=2687717861&term=pc&ver=5603&filesize=1815167&range=0&ukey=**********************************************) invalid: 404 Not Found. Text: "" at io.ktor.client.features.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invokeSuspend(DefaultResponseValidation.kt:39) at io.ktor.client.features.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(DefaultResponseValidation.kt) at io.ktor.client.features.HttpCallValidator.validateResponse(HttpCallValidator.kt:54) at io.ktor.client.features.HttpCallValidator$Companion$install$3.invokeSuspend(HttpCallValidator.kt:129) at io.ktor.client.features.HttpCallValidator$Companion$install$3.invoke(HttpCallValidator.kt) at io.ktor.client.features.HttpSend$Feature$install$1.invokeSuspend(HttpSend.kt:99) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ... 25 more Suppressed: io.ktor.client.features.ClientRequestException: Client request(http://123.150.76.171:80/cgi-bin/httpconn?htcmd=0x6ff0070&uin=2687717861&term=pc&ver=5603&filesize=1815167&range=0&ukey=**********************************************) invalid: 404 Not Found. Text: "" ... 32 more Suppressed: io.ktor.client.features.ClientRequestException: Client request(http://59.36.121.64:8080/cgi-bin/httpconn?htcmd=0x6ff0070&uin=2687717861&term=pc&ver=5603&filesize=1815167&range=0&ukey=**********************************************) invalid: 404 Not Found. Text: "" ... 32 more Suppressed: io.ktor.client.features.ClientRequestException: Client request(http://183.3.233.225:443/cgi-bin/httpconn?htcmd=0x6ff0070&uin=2687717861&term=pc&ver=5603&filesize=1815167&range=0&ukey=**********************************************) invalid: 404 Not Found. Text: "" ... 32 more >
-
然后就变成了神秘的东西,地址打开就是空的,什么都没有。
该网页无法正常运作180.97.117.144 未发送任何数据。 ERR_EMPTY_RESPONSE
-
尝试重启并删除
bots/***/cache
内的内容 -
并确定你正在尝试发送的图片是一个有效图片
-
@karlatemp 我尝试使用本地图片就全出错了,可以帮我找找原因吗?采用的url的input流才可以正常工作,但是本地图片是刚需,确定图片可以正常打开。
ExternalResource externalResource = ExternalResource.create(new File("/Users/zhaolong/Downloads/IMG_5785.jpg")); event.getFriend().Companion.sendImage(event.getFriend(), externalResource);
-
请提供出错的图片原图片
-
@karlatemp 慢着,论坛提示了不受支持的格式?这不是jpg吗,啊这,难道真是我文件问题导致的吗。。。
-
如果发送不了你可以打包成 zip 或者发送邮件至
k@mamoe.net
-
@karlatemp 没事了,这个图有问题,我本地打得开,但是除了本地其他的都打不开……
另请问,我这么上传图片发送是否比较合适?请问是否有其他更为合适或者常用的方式呢? -
-
@karlatemp 感谢,问题已解决。