mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-21 08:24:43 +08:00
Fix reconnection on Heartbeat timeout: add PacketTimeoutException
This commit is contained in:
parent
59e60d42ce
commit
2713127466
@ -14,6 +14,7 @@ import net.mamoe.mirai.internal.network.component.ComponentKey
|
||||
import net.mamoe.mirai.internal.network.component.ComponentStorage
|
||||
import net.mamoe.mirai.internal.network.context.SsoProcessorContext
|
||||
import net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport
|
||||
import net.mamoe.mirai.internal.network.handler.selector.PacketTimeoutException
|
||||
import net.mamoe.mirai.utils.BotConfiguration.HeartbeatStrategy.*
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.info
|
||||
@ -101,11 +102,11 @@ internal class TimeBasedHeartbeatSchedulerImpl(
|
||||
}
|
||||
|
||||
try {
|
||||
withTimeoutOrNull(timeout()) {
|
||||
withTimeout(timeout()) {
|
||||
action()
|
||||
} ?: error("Timeout $name.")
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
onHeartFailure(name, e)
|
||||
onHeartFailure(name, PacketTimeoutException("Timeout receiving Heartbeat response", e))
|
||||
}
|
||||
}
|
||||
}.apply {
|
||||
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.network.handler.selector
|
||||
|
||||
internal data class PacketTimeoutException(
|
||||
override val message: String,
|
||||
override val cause: Throwable? = null,
|
||||
) : NetworkException(true)
|
@ -10,7 +10,6 @@
|
||||
package net.mamoe.mirai.internal.network.impl.netty
|
||||
|
||||
import net.mamoe.mirai.internal.network.handler.selector.NetworkException
|
||||
import net.mamoe.mirai.utils.unwrap
|
||||
import net.mamoe.mirai.utils.unwrapCancellationException
|
||||
import java.io.IOException
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user