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

更换WiFi时短暂断网后不能成功重连,bot被closed #2488

Closed
MrY-Cat opened this issue Feb 10, 2023 · 4 comments · Fixed by #2505
Closed

更换WiFi时短暂断网后不能成功重连,bot被closed #2488

MrY-Cat opened this issue Feb 10, 2023 · 4 comments · Fixed by #2505
Labels
M 优先级: 主要 s:core 子系统: mirai-core t:bug 类型: bug
Milestone

Comments

@MrY-Cat
Copy link
Contributor

MrY-Cat commented Feb 10, 2023

问题描述

网络波动后bot被closed,不知道是否与今天升级到2.14.0有关。我记得以前断网数小时,再联网后也会自动重连。现在怎么短暂断网就被closed了,想知道是新版本对重连次数加了什么上限么还是其他原因造成。

复现

当设备更换WiFi时可能会发生。

mirai-core 版本

2.14.0

bot-protocol

ANDROID_PAD

其他组件版本

No response

系统日志

No response

网络日志

�[93m2023-02-10 19:48:58 W/Net 2305339556: Exception in resumeConnection.
HeartbeatFailedException: 2305339556.AliveHeartbeat, recoverable=true, cause=PacketTimeoutException(message=2305339556.AliveHeartbeat Scheduler: Timeout receiving action response, cause=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms)
	at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1$1.invoke(CommonNetworkHandler.kt:346)
	at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1$1.invoke(CommonNetworkHandler.kt:346)
	at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.setStateImpl$mirai_core(NetworkHandlerSupport.kt:329)
	at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1.invoke(CommonNetworkHandler.kt:408)
	at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1.invoke(CommonNetworkHandler.kt:345)
	at net.mamoe.mirai.internal.network.components.TimeBasedHeartbeatSchedulerImpl$launchHeartbeatJobAsync$1.invokeSuspend(HeartbeatScheduler.kt:131)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	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)
Caused by: PacketTimeoutException(message=2305339556.AliveHeartbeat Scheduler: Timeout receiving action response, cause=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms)
	at net.mamoe.mirai.internal.network.components.TimeBasedHeartbeatSchedulerImpl$launchHeartbeatJobAsync$1.invokeSuspend(HeartbeatScheduler.kt:133)
	... 12 more
Caused by: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
	at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
	at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
	at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
	at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
	at java.base/java.lang.Thread.run(Thread.java:833)
�[0m
�[0m2023-02-10 19:48:58 V/Net 2305339556: Validated caches.�[0m
�[0m2023-02-10 19:48:58 V/Net 2305339556: Loading server list from cache.�[0m
�[0m2023-02-10 19:48:58 V/Net 2305339556: Server list: 125.39.196.178:80, 59.83.208.153:80, 116.130.229.191:80, 220.194.118.217:14000, msfwifi.3g.qq.com:8080, 112.86.231.155:443, 60.29.242.161:80, 59.83.207.217:14000, 157.148.54.17:8080, 157.148.54.249:443.�[0m
�[92m2023-02-10 19:48:58 I/Net 2305339556: ECDH key is valid.�[0m
�[0m2023-02-10 19:48:58 V/Net 2305339556: Send: wtlogin.exchange_emp(10:fast-login)�[0m
�[0m2023-02-10 19:49:03 V/Net 2305339556: Send: wtlogin.exchange_emp(10:fast-login)�[0m
�[0m2023-02-10 19:49:08 V/Net 2305339556: Send: wtlogin.login(9:password-login)�[0m
�[0m2023-02-10 19:49:13 V/Net 2305339556: Send: wtlogin.login(9:password-login)�[0m
�[93m2023-02-10 19:49:18 W/Net 2305339556: Exception in resumeConnection.
kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
	at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
	at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
	at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
	at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
	at java.base/java.lang.Thread.run(Thread.java:833)
�[0m
�[93m2023-02-10 19:49:18 W/Net 2305339556: Network selector received exception, closing bot. (kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms)�[0m
�[93m2023-02-10 19:49:18 W/Net 2305339556: Exception in resumeConnection.
kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
	at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
	at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
	at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
	at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
	at java.base/java.lang.Thread.run(Thread.java:833)
	Suppressed: HeartbeatFailedException: 2305339556.AliveHeartbeat, recoverable=true, cause=PacketTimeoutException(message=2305339556.AliveHeartbeat Scheduler: Timeout receiving action response, cause=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms)
		at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1$1.invoke(CommonNetworkHandler.kt:346)
		at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1$1.invoke(CommonNetworkHandler.kt:346)
		at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.setStateImpl$mirai_core(NetworkHandlerSupport.kt:329)
		at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1.invoke(CommonNetworkHandler.kt:408)
		at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateOK$heartbeatJobs$1.invoke(CommonNetworkHandler.kt:345)
		at net.mamoe.mirai.internal.network.components.TimeBasedHeartbeatSchedulerImpl$launchHeartbeatJobAsync$1.invokeSuspend(HeartbeatScheduler.kt:131)
		at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
		at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
		at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
		at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
		at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
		at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
		at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
		at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
		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)
	Caused by: PacketTimeoutException(message=2305339556.AliveHeartbeat Scheduler: Timeout receiving action response, cause=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms)
		at net.mamoe.mirai.internal.network.components.TimeBasedHeartbeatSchedulerImpl$launchHeartbeatJobAsync$1.invokeSuspend(HeartbeatScheduler.kt:133)
		... 12 more
	Caused by: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
		at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
		at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
		at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
		at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
		at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
		at java.base/java.lang.Thread.run(Thread.java:833)
�[0m
�[93m2023-02-10 19:49:18 W/Net 2305339556: Network selector received exception, closing bot. (kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms)�[0m

补充信息

No response

@MrY-Cat MrY-Cat changed the title 短暂断网后不能成功重连,bot被closed 更换WiFi时短暂断网后不能成功重连,bot被closed Feb 11, 2023
@sandtechnology
Copy link
Collaborator

sandtechnology commented Feb 11, 2023

应该是 38162db 导致
继承关系为 kotlinx.coroutines.TimeoutCancellationException -> java.util.concurrent.CancellationException -> java.lang.IllegalStateException
EDITED: 哦这个是测试 不过能说明就是因为没有warp起TimeoutCancellationException导致的问题

@MrY-Cat
Copy link
Contributor Author

MrY-Cat commented Feb 11, 2023

更换WiFi或者WiFi信号若的时候经常发生,好难受

@MrY-Cat
Copy link
Contributor Author

MrY-Cat commented Feb 11, 2023

应该是 38162db 导致 继承关系为 kotlinx.coroutines.TimeoutCancellationException -> java.util.concurrent.CancellationException -> java.lang.IllegalStateException EDITED: 哦这个是测试 不过能说明就是因为没有warp起TimeoutCancellationException导致的问题

那是不是也比较容易解决呀,我觉得还是以前版本那样的好,断网之后就算过了几小时只要再联网还可以自动连上

@zzturn
Copy link

zzturn commented Feb 12, 2023

出现同样的情况
Running MiraiConsole v2.13.4, built on 2023-01-21 21:19:40.
Frontend Terminal: version 2.13.4, provided by Mamoe Technologies

sandtechnology added a commit to sandtechnology/mirai that referenced this issue Feb 15, 2023
@Him188 Him188 added this to the 2.15.0-RC milestone Feb 18, 2023
@Him188 Him188 added t:bug 类型: bug M 优先级: 主要 s:core 子系统: mirai-core labels Feb 18, 2023
Him188 pushed a commit that referenced this issue Feb 19, 2023
 #2504, fix #2488 (#2505)

* #2504,#2488 handle TimeoutCancellationException when resuming connection

* Remove unnecessary code and fix wording

* Use yield() instead of delay

* Use yield() instead of delay
@Him188 Him188 modified the milestones: 2.15.0-RC, 2.15.0-M1 Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M 优先级: 主要 s:core 子系统: mirai-core t:bug 类型: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants