mamoe / mirai

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

java.lang.IllegalStateException: wLoginSigInfoField is not yet initialized #2449

Closed zhaodice closed 1 year ago

zhaodice commented 1 year ago

问题描述

用的 https://github.com/mamoe/mirai/actions/runs/3933352388 的action版本 挂机一晚上后发现断线且没有自动重连,似乎是重连条件出现误判? 重启后完全正常,故而这个问题并不紧急,只是先提出来放在这里

复现

挂机一晚上加一上午,不太好复现

mirai-core 版本

1.14.0(ACTION 3933352388)

bot-protocol

ANDROID_PHONE

其他组件版本

No response

系统日志

[11:29:56] [INFO] ECDH key is valid. 
[11:29:56] [ERROR] Error while decoding packet 'ByteReadPacket(0 bytes remaining)' 
[11:29:56] [ERROR] net.mamoe.mirai.internal.network.components.PacketCodecException: java.lang.IllegalStateException: Received packet returnCode = -10008, which may mean session expired.
    at net.mamoe.mirai.internal.network.components.PacketCodecImpl.parseSsoFrame(PacketCodec.kt:178)
    at net.mamoe.mirai.internal.network.components.PacketCodecImpl.decodeRaw(PacketCodec.kt:128)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline.decodePacket(CommonNetworkHandler.kt:148)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline.access$decodePacket(CommonNetworkHandler.kt:102)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline$1.invokeSuspend(CommonNetworkHandler.kt:125)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalStateException: Received packet returnCode = -10008, which may mean session expired.
    ... 14 more

[11:29:56] [INFO] parserXml failed, then return false 
[11:29:56] [WARNING] Exception in resumeConnection. 
[11:29:56] [WARNING] Network selector received exception, closing bot. (java.lang.IllegalStateException: NetworkHandler is already closed.) 
[11:29:56] [WARNING] Exception in resumeConnection. 
[11:29:56] [INFO] ECDH key is invalid, start to fetch ecdh public key from server. 
[11:29:56] [INFO] Successfully fetched ecdh public key from server. 
[11:29:57] [ERROR] Exception in coroutine 'unnamed' 
[11:29:57] [ERROR] ExceptionInPacketCodecException(cause=java.lang.IllegalStateException: wLoginSigInfoField is not yet initialized)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler.handleExceptionInDecoding$passToExceptionHandler(CommonNetworkHandler.kt:57)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler.handleExceptionInDecoding(CommonNetworkHandler.kt:74)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline$1.invokeSuspend(CommonNetworkHandler.kt:129)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalStateException: wLoginSigInfoField is not yet initialized
    at net.mamoe.mirai.internal.network.components.AccountSecrets.getWLoginSigInfo(AccountSecretsManager.kt:55)
    at net.mamoe.mirai.internal.network.QQAndroidClient.getWLoginSigInfo(Unknown Source:2)
    at net.mamoe.mirai.internal.network.components.PacketCodecImpl.decodeRaw(PacketCodec.kt:122)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline.decodePacket(CommonNetworkHandler.kt:148)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline.access$decodePacket(CommonNetworkHandler.kt:102)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline$1.invokeSuspend(CommonNetworkHandler.kt:125)
    ... 9 more

[11:29:57] [ERROR] Error while decoding packet 'ByteReadPacket(0 bytes remaining)' 
[11:29:57] [ERROR] java.lang.IllegalStateException: wLoginSigInfoField is not yet initialized
    at net.mamoe.mirai.internal.network.components.AccountSecrets.getWLoginSigInfo(AccountSecretsManager.kt:55)
    at net.mamoe.mirai.internal.network.QQAndroidClient.getWLoginSigInfo(Unknown Source:2)
    at net.mamoe.mirai.internal.network.components.PacketCodecImpl.decodeRaw(PacketCodec.kt:122)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline.decodePacket(CommonNetworkHandler.kt:148)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline.access$decodePacket(CommonNetworkHandler.kt:102)
    at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$PacketDecodePipeline$1.invokeSuspend(CommonNetworkHandler.kt:125)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:919)

[11:29:57] [INFO] Login successful 
[11:29:57] [INFO] Saved account secrets to local cache for fast login. 
[11:29:57] [INFO] Login successful. 
[11:29:57] [INFO] Server time updated, serverTime: 1674271797, diff: 0ms=0.0s 
[11:29:57] [INFO] Scheduled refresh login session in 19d 23h 55min 0.0s. 
[11:29:57] [INFO] Scheduled key refresh in 23h 55min 0.0s. 
[11:29:57] [INFO] Bot is closed manually with exception: java.lang.IllegalStateException: NetworkHandler is already closed. 
[11:29:57] [INFO] Bot cancelled: Bot closed 

### 网络日志

```text
暂时没有打开log功能,如有需要这里可以试图重新复现进行补充

补充信息

No response

zhaodice commented 1 year ago

似乎和 #2447 的错误差不多,但我这个是挂机很久很久才出现的,当时是完全正常,出问题重启后也完全正常

cssxsh commented 1 year ago

Received packet returnCode = -10008, which may mean session expired.

session cacahe 过期了

zhaodice commented 1 year ago

Received packet returnCode = -10008, which may mean session expired.

session cacahe 过期了

但是重启之后就正常了,也许可以加个自动重连逻辑?

cssxsh commented 1 year ago

自动重连逻辑 本来就有 你这里遇到了失效的情况,网络层断掉了

类似的 issue 有提过 https://github.com/mamoe/mirai/issues/2148