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 {
|
||||
suspend fun reconnect(event: BotOfflineEvent): Boolean {
|
||||
while (true) {
|
||||
retryCatchingExceptions<Unit>(
|
||||
configuration.reconnectionRetryTimes,
|
||||
except = LoginFailedException::class
|
||||
@ -193,16 +192,17 @@ internal abstract class AbstractBot<N : BotNetworkHandler> constructor(
|
||||
}.getOrElse { exception ->
|
||||
if (exception is LoginFailedException && !exception.killBot) {
|
||||
logger.info { "Cannot reconnect." }
|
||||
logger.warning(exception)
|
||||
logger.info { "Retrying in 3s..." }
|
||||
delay(3000)
|
||||
return@getOrElse
|
||||
}
|
||||
logger.info { "Cannot reconnect due to fatal error." }
|
||||
bot.cancel(CancellationException("Cannot reconnect due to fatal error.", exception))
|
||||
logger.error(exception)
|
||||
// logger.info { "Retrying in 3s..." }
|
||||
// delay(3000)
|
||||
return false
|
||||
}
|
||||
logger.info { "Cannot reconnect." }
|
||||
bot.cancel(CancellationException("Cannot reconnect.", exception))
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user