project-mirai / mirai-api-http

Mirai HTTP API (console) plugin
GNU Affero General Public License v3.0
1.66k stars 343 forks source link

websocket adapter报错java.lang.NoSuchMethodError且不推送message #574

Closed reallyimeric closed 2 years ago

reallyimeric commented 2 years ago

一旦成功连接到ws后,每收到一条群消息,就可以看到一堆java的错误堆栈信息,并且客户端无法收到message

重现

  1. 启动mirai并登录,确定已经开始正常收到qq消息
  2. const socket = new ws.WebSocket('ws://host:port/all?verifyKey=xxxxx&qq=xxxxx')
  3. mirai-console上每一条群消息下可以看到一些错误,且socketmessage事件回调一直不会被调用

预期行为 没有报错且正常向客户端推送message

错误日志

2022-05-15 14:24:34 V/Bot.xxxxx: [群名字(xxxxx)] 群成员(xxxxxxx) -> 群消息群消息群消息
2022-05-15 14:24:34 W/stderr: Exception in thread "DefaultDispatcher-worker-4" java.lang.reflect.InvocationTargetException: 'void kotlinx.serialization.PolymorphicSerializer.<init>(kotlin.reflect.KClass, java.lang.annotation.Annotation[])'
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.internal.PlatformKt.invokeSerializerOnCompanion(Platform.kt:106)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.internal.PlatformKt.constructSerializerForGivenTypeArgs(Platform.kt:41)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.internal.PlatformKt.compiledSerializerImpl(Platform.kt:23)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.SerializersKt__SerializersKt.serializerOrNull(Serializers.kt:178)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.SerializersKt.serializerOrNull(Unknown Source)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.SerializersKt__SerializersKt.serializer(Serializers.kt:155)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.SerializersKt.serializer(Unknown Source)
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.adapter.internal.serializer.BuiltinJsonSerializer.encodeElement(BuiltinJson.kt:68)
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.adapter.ws.WebsocketAdapter.offerChannel(WebsocketAdapter.kt:98)
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.adapter.ws.WebsocketAdapter.onReceiveBotEvent(WebsocketAdapter.kt:53)
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.context.MahContext$handleBotEvent$1$1.invokeSuspend(MahContext.kt:116)
2022-05-15 14:24:34 W/stderr:   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2022-05-15 14:24:34 W/stderr:   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2022-05-15 14:24:34 W/stderr:   at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)2022-05-15 14:24:34 W/stderr:   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
2022-05-15 14:24:34 W/stderr:   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
2022-05-15 14:24:34 W/stderr:   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
2022-05-15 14:24:34 W/stderr: Caused by: java.lang.NoSuchMethodError: 'void kotlinx.serialization.PolymorphicSerializer.<init>(kotlin.reflect.KClass, java.lang.annotation.Annotation[])'
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.adapter.internal.dto.EventDTO$Companion$$cachedSerializer$delegate$1.invoke(base.kt:16)
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.adapter.internal.dto.EventDTO$Companion$$cachedSerializer$delegate$1.invoke(base.kt:16)
2022-05-15 14:24:34 W/stderr:   at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
2022-05-15 14:24:34 W/stderr:   at net.mamoe.mirai.api.http.adapter.internal.dto.EventDTO$Companion.serializer(base.kt:16)
2022-05-15 14:24:34 W/stderr:   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
2022-05-15 14:24:34 W/stderr:   at java.base/java.lang.reflect.Method.invoke(Method.java:577)
2022-05-15 14:24:34 W/stderr:   at kotlinx.serialization.internal.PlatformKt.invokeSerializerOnCompanion(Platform.kt:101)
2022-05-15 14:24:34 W/stderr:   ... 16 more

版本信息

reallyimeric commented 2 years ago

在websocket连接关闭后,console上不再出现报错

ryoii commented 2 years ago

2.5.0 的插件需要升级到 2.11 的core

crskycode commented 2 years ago

2.5.0 的插件需要升级到 2.11 的core

如何升级Core模块?我使用IDEA构建后没有找到mirai-core-all-****.jar这样的包。

更新: 使用mcl将core的channel改为beta后执行update问题解决。