From ec176a05e12bba960e4a54f442eaaf5543e44a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Fr=C3=A4nkel?= Date: Tue, 24 Feb 2026 00:56:43 -0400 Subject: [PATCH] fix: use fetchLatestWaWebVersion to prevent 405 connection failures (#443) Baileys' default WhatsApp version can fall behind when WhatsApp updates their protocol, causing 405 "Method Not Allowed" errors on the websocket handshake. This prevents both new authentication and reconnection. Now fetches the latest version on each connection so it stays current. Applied to both the runtime connection (whatsapp.ts) and the setup auth flow (whatsapp-auth.ts). --- src/channels/whatsapp.ts | 3 +++ src/whatsapp-auth.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/channels/whatsapp.ts b/src/channels/whatsapp.ts index 02d814e..a62cf7a 100644 --- a/src/channels/whatsapp.ts +++ b/src/channels/whatsapp.ts @@ -6,6 +6,7 @@ import makeWASocket, { Browsers, DisconnectReason, WASocket, + fetchLatestWaWebVersion, makeCacheableSignalKeyStore, useMultiFileAuthState, } from '@whiskeysockets/baileys'; @@ -55,7 +56,9 @@ export class WhatsAppChannel implements Channel { const { state, saveCreds } = await useMultiFileAuthState(authDir); + const { version } = await fetchLatestWaWebVersion({}); this.sock = makeWASocket({ + version, auth: { creds: state.creds, keys: makeCacheableSignalKeyStore(state.keys, logger), diff --git a/src/whatsapp-auth.ts b/src/whatsapp-auth.ts index a969835..264b22b 100644 --- a/src/whatsapp-auth.ts +++ b/src/whatsapp-auth.ts @@ -15,6 +15,7 @@ import readline from 'readline'; import makeWASocket, { Browsers, DisconnectReason, + fetchLatestWaWebVersion, makeCacheableSignalKeyStore, useMultiFileAuthState, } from '@whiskeysockets/baileys'; @@ -53,7 +54,9 @@ async function connectSocket(phoneNumber?: string, isReconnect = false): Promise process.exit(0); } + const { version } = await fetchLatestWaWebVersion({}); const sock = makeWASocket({ + version, auth: { creds: state.creds, keys: makeCacheableSignalKeyStore(state.keys, logger),