mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-02 04:30:25 +08:00
Fix endless reconnection on LoginFailedException, close #895
This commit is contained in:
parent
ff9cc6a74e
commit
af9eadf34e
@ -163,7 +163,6 @@ internal abstract class AbstractBot<N : BotNetworkHandler> constructor(
|
|||||||
|
|
||||||
private inner class Reconnect {
|
private inner class Reconnect {
|
||||||
suspend fun reconnect(event: BotOfflineEvent): Boolean {
|
suspend fun reconnect(event: BotOfflineEvent): Boolean {
|
||||||
while (true) {
|
|
||||||
retryCatchingExceptions<Unit>(
|
retryCatchingExceptions<Unit>(
|
||||||
configuration.reconnectionRetryTimes,
|
configuration.reconnectionRetryTimes,
|
||||||
except = LoginFailedException::class
|
except = LoginFailedException::class
|
||||||
@ -193,16 +192,17 @@ internal abstract class AbstractBot<N : BotNetworkHandler> constructor(
|
|||||||
}.getOrElse { exception ->
|
}.getOrElse { exception ->
|
||||||
if (exception is LoginFailedException && !exception.killBot) {
|
if (exception is LoginFailedException && !exception.killBot) {
|
||||||
logger.info { "Cannot reconnect." }
|
logger.info { "Cannot reconnect." }
|
||||||
logger.warning(exception)
|
logger.error(exception)
|
||||||
logger.info { "Retrying in 3s..." }
|
// logger.info { "Retrying in 3s..." }
|
||||||
delay(3000)
|
// delay(3000)
|
||||||
return@getOrElse
|
|
||||||
}
|
|
||||||
logger.info { "Cannot reconnect due to fatal error." }
|
|
||||||
bot.cancel(CancellationException("Cannot reconnect due to fatal error.", exception))
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
logger.info { "Cannot reconnect." }
|
||||||
|
bot.cancel(CancellationException("Cannot reconnect.", exception))
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user