Open SuhailTechInfo opened 5 months ago
sock.ev.on('connection.update', async({ connection, lastDisconnect, receivedPendingNotifications }) => {
const status = lastDisconnect?.error?.output?.statusCode
if (connection === 'close'){
const reason = Object.entries(DisconnectReason).find(i => i[1] === status)?.[0] || 'unknown'
console.log(`Connection closed, status: ${status} - ${reason}`)
if (status !== 403 && status !== 401 && status){
connectToWhatsApp()
}
} else if (connection === 'open'){
console.log('Connected with success')
if (receivedPendingNotifications && !sock.authState.creds?.myAppStateKeyId){
sock.ev.flush() // this
}
}
})
sock.ev.on('connection.update', async({ connection, lastDisconnect, receivedPendingNotifications }) => { const status = lastDisconnect?.error?.output?.statusCode if (connection === 'close'){ const reason = Object.entries(DisconnectReason).find(i => i[1] === status)?.[0] || 'unknown' console.log(`Connection closed, status: ${status} - ${reason}`) if (status !== 403 && status !== 401 && status){ connectToWhatsApp() } } else if (connection === 'open'){ console.log('Connected with success') if (receivedPendingNotifications && !sock.authState.creds?.myAppStateKeyId){ sock.ev.flush() // this } } })
Do you mind explaining the use of receivedPendingNotifications && !sock.authState.creds?.myAppStateKeyId
logic here? Thanks
sock.ev.on('connection.update', async({ connection, lastDisconnect, receivedPendingNotifications }) => { const status = lastDisconnect?.error?.output?.statusCode if (connection === 'close'){ const reason = Object.entries(DisconnectReason).find(i => i[1] === status)?.[0] || 'unknown' console.log(`Connection closed, status: ${status} - ${reason}`) if (status !== 403 && status !== 401 && status){ connectToWhatsApp() } } else if (connection === 'open'){ console.log('Connected with success') if (receivedPendingNotifications && !sock.authState.creds?.myAppStateKeyId){ sock.ev.flush() // this } } })
Do you mind explaining the use of
receivedPendingNotifications && !sock.authState.creds?.myAppStateKeyId
logic here? Thanks
If there are received pending notifications and the myAppStateKeyId is not present in creds then flush
sock.ev.on('connection.update', async({ connection, lastDisconnect, receivedPendingNotifications }) => { const status = lastDisconnect?.error?.output?.statusCode if (connection === 'close'){ const reason = Object.entries(DisconnectReason).find(i => i[1] === status)?.[0] || 'unknown' console.log(`Connection closed, status: ${status} - ${reason}`) if (status !== 403 && status !== 401 && status){ connectToWhatsApp() } } else if (connection === 'open'){ console.log('Connected with success') if (receivedPendingNotifications && !sock.authState.creds?.myAppStateKeyId){ sock.ev.flush() // this } } })
i have tried to use flush() method. but still same issue,
receivedPendingNotifications
is undefined
in my case.
console.log({receivedPendingNotifications })
// OUTPUT {receivedPendingNotifications :undefined}
<br>
- Also `myAppStateKeyId` is present in `creds.json`
## ANY OTHER SOLUTION FOR `message.upsert` NOT WORKING?
because of this problem i can't use official baileys , thanks for your help
Then what's you're using Currently?
This makes the trick
sock.ev.on('connection.update', async({ connection, lastDisconnect, receivedPendingNotifications }) => {
const status = lastDisconnect?.error?.output?.statusCode
if (connection === 'close'){
const reason = Object.entries(DisconnectReason).find(i => i[1] === status)?.[0] || 'unknown'
console.log(`Connection closed, status: ${status} - ${reason}`)
if (status !== 403 && status !== 401 && status){
connectToWhatsApp()
}
} else if (connection === 'open'){
console.log('Connected with success')
sock.ev.flush() // this
}
})
still issue
i have some problem @SuhailTechInfo you use ipv6?
Here are some of my findings:
The following can make an error in your auth file, which allows you to send messages but not receive any:
shouldSyncHistoryMessage(_msg) {
return false;
},
or / and :
shouldIgnoreJid(jid) {
return jid !== SPECIFIC_PHONE_NUMBER;
}
Also, on first login (after qr), the phone sync/transmits data to your baileys client, which takes some time - so you shouldn't close the connection straight away, wait atleast 20-30 seconds before closing
BUG
ANY SOLUTION FOR
message.upsert
NOT WORKING?WAHTSAPP SOCKET: