mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 20:12:02 -06:00
refactor: update reconnection logic to prevent reconnection in cases of banishment or blocking
Handled specific errors to improve reconnection logic: - 401: Triggered logout to handle unauthorized access. - 402: Recognized as temporary ban, reconnection attempts paused. - 403: Recognized as forbidden, reconnection attempts stopped. - 406: Recognized as permanent ban, reconnection attempts halted.
This commit is contained in:
parent
d82945a735
commit
258f56759c
@ -388,7 +388,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
if (connection === 'close') {
|
||||
const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut;
|
||||
const statusCode = (lastDisconnect?.error as Boom)?.output?.statusCode;
|
||||
const codesToNotReconnect = [DisconnectReason.loggedOut, DisconnectReason.forbidden, 402, 406];
|
||||
const shouldReconnect = !codesToNotReconnect.includes(statusCode);
|
||||
if (shouldReconnect) {
|
||||
await this.connectToWhatsapp(this.phoneNumber);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user