Fix WhatsApp connection 405 by fetching latest version

This commit is contained in:
Hamza-Ayed
2026-05-23 17:17:07 +03:00
parent 57f3529900
commit d4c5576c2f

View File

@@ -57,9 +57,9 @@ async function startSession(session_key, webhook_url) {
const sessionFolder = path.join(SESSIONS_DIR, session_key);
const { state, saveCreds } = await useMultiFileAuthState(sessionFolder);
// Use a hardcoded stable version to prevent parsed timestamp version errors which reject pairing
const version = [2, 3000, 1017, 0];
console.log(`[Baileys] Using stable WA version: ${version}`);
// Fetch the latest version from WhatsApp web to prevent 405 Connection Failure
const { version, isLatest } = await fetchLatestBaileysVersion();
console.log(`[Baileys] Using WA version: ${version} (isLatest: ${isLatest})`);
const logger = pino({ level: 'silent' });