Baileys: [BUG] Failure to Connect After Scanning QR Code
Bug: I M using this WhiskeySockets library for a long time without encountering this error, but it occurred unexpectedly today.
Sample Code Of Qr:
import makeWASocket, { DisconnectReason, BufferJSON, useMultiFileAuthState } from '@whiskeysockets/baileys'
import { Boom } from '@hapi/boom'
async function connectToWhatsApp () {
const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
});
sock.ev.on('creds.update', saveCreds)
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update
if (connection === 'close') {
const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
console.log('Connection closed due to', lastDisconnect?.error, ', reconnecting', shouldReconnect)
if (shouldReconnect) {
connectToWhatsApp() // Reconnect if necessary
}
} else if (connection === 'open') {
console.log('Opened connection')
}
});
sock.ev.on('messages.upsert', m => {
console.log("Message Received: " + m.messages[0].key.remoteJid);
});
}
connectToWhatsApp()
To Reproduce:
- Create a new connection.
- Scan the QR code.
- Observe the connection failure.
Expected Behavior: After scanning the QR code, the connection should be established successfully, allowing communication with WhatsApp.
Environment:
- Running on a local machine.
connectOptions:- makeWASocket({ auth: state, printQRInTerminal: true, });
- No multiple clients on the same IP.
- Not using a proxy.
Additional Context:
- The issue occurs consistently, leading to a failure to establish a connection with WhatsApp.
- The behavior was observed while attempting to connect to WhatsApp using the Baileys library.
- The code logic is correct, but the connection fails after scanning the QR code.
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 18
- Comments: 96 (6 by maintainers)
Commits related to this issue
- Fix platform types Fixes #701 and #702. — committed to WhiskeySockets/Baileys by SheIITear 3 months ago
- merge (#730) * fix(#681): Fixed import (credit to #611) * Update FUNDING.yml * Fix platform types Fixes #701 and #702. --------- Co-authored-by: ShellTear <shelltear1337@gmail.com> Co... — committed to WhiskeySockets/Baileys by PurpShell 3 months ago
Till it gets merged you can try using this branch -> https://github.com/WhiskeySockets/Baileys/tree/fix-516
Temporary solution: downgrade to Baileys v5.0.0
Procedure to downgrade if you are using Arrocy Whatsapp Gateway:
Hello team, my full support to you
yes i have 45 previously connected +91 numbers without No issue, Issue with new number connectivity.
I see this issue only in baileys library other library working 100% perfectly i tested on 3 other scripts not using baileys. So no whatsapp server side filter or country restriction or planning to stop unofficial whatsapp etc. Let’s wait for baileys master mind to resolve this.
Yah bro i fix inrl ban issue today but, this issue ☕
Yaa am also faceing this issue in new connection…!!
Ok, I tested with +254 number (@V-E-N-O-X brought up having the same issue with them) that has not been used before on few different servers and had no problems. I still cannot reproduce this unfortunately. I’ll try to find a number from India that I can use to test.
Yes without proxy working and all old devices will be stay connected
a. yes, using proxyscrape.com b. no change, direct replacement. Baileys-v6 folder -> replace with ->Baileys-v5 folder
It’s a issue related login to foreign country yesterday I checked with my pair when I try to login with that hosted on koyeb it’s disconnected my device and when I’m try after turn on in Termux it’s connected successfully
Thank you. This is i know what it should be let me try and get back to you here. You may now remove the link 😃
Thank you for quick reply please mention the link. i know one other script but that uses RAM a lot like 700-800MB ram per instance. Still please mention the script link
It works in other PC, also it works in browser from that PC too. Only baileys doesn’t work. Tried official android Whatsapp normal beta and iphone whatsapp business.
Hey, after testing with multiple devices i found that the issue seems with the ip address when anyone uses Indian number with a new ip it works fine. As you mentioned that you dont have Indian number access i can help you to have one to test it and solve the problem for the world. I had one more question i used the proxy url in order to connect baileys however i was not getting the connection done using proxy i wonder why.
It’s Also Working For Me feeling Sad For +91
Meta has started to fight against unofficial libraries I guess. The starting may be from India as there are a major no. of Indian users. Edit: It’s just my assumption, I’m not a piro!
I think only Indian numbers/accounts are facing this issue rn. Tested on other regions, no issues! Seems strange 😕