Baileys
Baileys copied to clipboard
[BUG] When sending message
Hello, I'm having this error when trying to send messages to groups.
Failed to decrypt message with any known session... Session error:MessageCounterError: Key used already or never filled MessageCounterError: Key used already or never filled at SessionCipher.doDecryptWhisperMessage (/home/-/-/node_modules/libsignal/src/session_cipher.js:236:19)
I've tried to rescan the session and it follows.
I'm using useMultiFileAuthState('...') as stated in the documentation
would anyone know what could be causing this?
can you share with us how you initialize the socket? https://github.com/WhiskeySockets/Baileys/blob/534b1ea778152fa77bee47da291e1f3f5c153091/Example/example.ts#L40
Of course, I'm using it that way:
socketConfig = {
defaultQueryTimeoutMs: undefined,
printQRInTerminal: false,
browser: ['Dashboard WPP', '', '3.0'],
logger: pino({
level: 'silent',
}),
generateHighQualityLinkPreview: true,
}
...
const { state, saveCreds } = await useMultiFileAuthState('sessiondata/' + this.key + '/')
this.authState = { state: state, saveCreds: saveCreds, keys: makeCacheableSignalKeyStore(state.keys) }
this.socketConfig.auth = this.authState.state
this.instance.sock = makeWASocket(this.socketConfig)
try to modify as in the example with respect to Auth in this way has not generated me error
try to modify as in the example with respect to Auth in this way has not generated me error
You catch the error when you are trying to send the message. For example: await sock.sendMessage(id, { text: 'hola' });
In some whatsapp works perfectly, but in others when trying to send to groups this error occurs and ends up restarting the session:
Failed to decrypt message with any known session...
Session error:Error: Bad MAC Error: Bad MAC
at Object.verifyMAC (/home/-/node_modules/libsignal/src/crypto.js:87:15)
at SessionCipher.doDecryptWhisperMessage (/home/-/node_modules/libsignal/src/session_cipher.js:250:16)
at async SessionCipher.decryptWithSessions (/home/-/node_modules/libsignal/src/session_cipher.js:147:29)
at async Object.5511971032330.0 [as awaitable] (/home/-/node_modules/libsignal/src/session_cipher.js:171:28)
at async _asyncQueueExecutor (/home/-/node_modules/libsignal/src/queue_job.js:20:29)
Failed to decrypt message with any known session...
Session error:Error: Bad MAC Error: Bad MAC
at Object.verifyMAC (/home/-/node_modules/libsignal/src/crypto.js:87:15)
at SessionCipher.doDecryptWhisperMessage (/home/-/node_modules/libsignal/src/session_cipher.js:250:16)
at async SessionCipher.decryptWithSessions (/home/-/node_modules/libsignal/src/session_cipher.js:147:29)
at async Object.5511971032330.0 [as awaitable] (/home/-/node_modules/libsignal/src/session_cipher.js:171:28)
at async _asyncQueueExecutor (/home/-/node_modules/libsignal/src/queue_job.js:20:29)
Failed to decrypt message with any known session...
Session error:Error: Bad MAC Error: Bad MAC
at Object.verifyMAC (/home/-/node_modules/libsignal/src/crypto.js:87:15)
at SessionCipher.doDecryptWhisperMessage (/home/-/node_modules/libsignal/src/session_cipher.js:250:16)
at async SessionCipher.decryptWithSessions (/home/-/node_modules/libsignal/src/session_cipher.js:147:29)
at async Object.5511971032330.0 [as awaitable] (/home/-/node_modules/libsignal/src/session_cipher.js:171:28)
at async _asyncQueueExecutor (/home/-/node_modules/libsignal/src/queue_job.js:20:29)
Failed to decrypt message with any known session...
Session error:Error: Bad MAC Error: Bad MAC
at Object.verifyMAC (/home/-/node_modules/libsignal/src/crypto.js:87:15)
at SessionCipher.doDecryptWhisperMessage (/home/-/node_modules/libsignal/src/session_cipher.js:250:16)
at async SessionCipher.decryptWithSessions (/home/-/node_modules/libsignal/src/session_cipher.js:147:29)
at async Object.5511971032330.0 [as awaitable] (/home/-/node_modules/libsignal/src/session_cipher.js:171:28)
at async _asyncQueueExecutor (/home/-/node_modules/libsignal/src/queue_job.js:20:29)
Failed to decrypt message with any known session...
Another error occurring, I don't know if this error is causing the aforementioned one. But some groups timed out, even whatsapp trying to fire being superadmin of the group
[svqlcyjduprwkm] ERRO AO ENVIAR MENSAGEM NO GRUPO -> [email protected] Error: Timed Out
at /home/-/node_modules/@whiskeysockets/baileys/lib/Utils/generics.js:159:32
at runNextTicks (node:internal/process/task_queues:61:5)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7) {
data: {
stack: 'Error\n' +
' at promiseTimeout (/home/-/node_modules/@whiskeysockets/baileys/lib/Utils/generics.js:154:19)\n' +
' at sendRawMessage (/home/-/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:54:42)\n' +
' at sendNode (/home/-/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:70:16)\n' +
' at /home/-/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:431:19\n' +
' at runMicrotasks (<anonymous>)\n' +
' at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
' at async Object.transaction (/home/-/node_modules/@whiskeysockets/baileys/lib/Utils/auth-utils.js:135:26)\n' +
' at async relayMessage (/home/-/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:276:9)\n' +
' at async Object.sendMessage (/home/-/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:637:17)\n' +
' at async /home/-/src/api/class/instance.js:986:20'
},
isBoom: true,
isServer: false,
output: {
statusCode: 408,
payload: {
statusCode: 408,
error: 'Request Time-out',
message: 'Timed Out'
},
headers: {}
}
}
I'm facing the same problem, any solution yet?
I have same error... Error: Timed Out at /home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Utils/generics.js:136:32 { data: { stack: 'Error\n' + ' at promiseTimeout (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Utils/generics.js:131:19)\n' + ' at waitForMessage (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:114:53)\n' + ' at query (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:136:22)\n' + ' at groupQuery (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/groups.js:12:55)\n' + ' at groupMetadata (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/groups.js:22:30)\n' + ' at /home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:288:47\n' + ' at /home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:291:23\n' + ' at Object.transaction (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Utils/auth-utils.js:136:32)\n' + ' at relayMessage (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:278:30)\n' + ' at Object.sendMessage (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:648:23)\n' + ' at async SendWhatsAppMessage (/home/deploy/whats/backend/dist/services/WbotServices/SendWhatsAppMessage.js:58:29)\n' + ' at async store (/home/deploy/whats/backend/dist/controllers/MessageController.js:54:9)' }, isBoom: true, isServer: false, output: { statusCode: 408, payload: { statusCode: 408, error: 'Request Time-out', message: 'Timed Out' }, headers: {} }
OBS: My project create in database 2 contacts, one contacts with "-" another Contacts whitout "-" See:
whats=# select * from "Contacts" where name like 'Amap%'; id | name | number | profilePicUrl | createdAt | updatedAt | email | isGroup | companyId -------+------------------+-------------------------+--------------------------------------------+----------------------------+----------------------------+-------+---------+---------- 1757 | Amapxxxxxxx | 5537###-xxx103 | https://xxxxxxx/nopicture.png | 2023-01-19 23:59:33.42+01 | 2023-01-19 23:59:33.42+01 | | t | 2 17495 | Amapxxxxxxx | 5537###xxx103 | https://xxxxxxx/nopicture.png | 2023-07-31 18:20:41.528+02 | 2023-07-31 18:20:41.528+02 | | t | 2
In contact whitout "-" I dont send any messages and receive error But i read all messages. In Contact have "-" I send messages but dont read any messages.
Same error
Is there a solution for this problem?
Hello, guys. I'm experiencing the same error. Has anyone been able to find a solution?
current-app-1 | Failed to decrypt message with any known session...
current-app-1 | Session error:Error: Bad MAC Error: Bad MAC
current-app-1 | at Object.verifyMAC (/home/node/app/node_modules/super-libsignal/src/crypto.js:87:15)
current-app-1 | at SessionCipher.doDecryptWhisperMessage (/home/node/app/node_modules/super-libsignal/src/session_cipher.js:250:16)
current-app-1 | at async SessionCipher.decryptWithSessions (/home/node/app/node_modules/super-libsignal/src/session_cipher.js:147:29)
current-app-1 | at async 5545920012998:61.0 [as awaitable] (/home/node/app/node_modules/super-libsignal/src/session_cipher.js:171:28)
current-app-1 | at async _asyncQueueExecutor (/home/node/app/node_modules/super-libsignal/src/queue_job.js:20:29)
I have same error... Error: Timed Out at /home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Utils/generics.js:136:32 { data: { stack: 'Error\n' + ' at promiseTimeout (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Utils/generics.js:131:19)\n' + ' at waitForMessage (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:114:53)\n' + ' at query (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:136:22)\n' + ' at groupQuery (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/groups.js:12:55)\n' + ' at groupMetadata (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/groups.js:22:30)\n' + ' at /home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:288:47\n' + ' at /home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:291:23\n' + ' at Object.transaction (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Utils/auth-utils.js:136:32)\n' + ' at relayMessage (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:278:30)\n' + ' at Object.sendMessage (/home/deploy/whats/backend/node_modules/@whiskeysockets/baileys/lib/Socket/messages-send.js:648:23)\n' + ' at async SendWhatsAppMessage (/home/deploy/whats/backend/dist/services/WbotServices/SendWhatsAppMessage.js:58:29)\n' + ' at async store (/home/deploy/whats/backend/dist/controllers/MessageController.js:54:9)' }, isBoom: true, isServer: false, output: { statusCode: 408, payload: { statusCode: 408, error: 'Request Time-out', message: 'Timed Out' }, headers: {} }
OBS: My project create in database 2 contacts, one contacts with "-" another Contacts whitout "-" See:
whats=# select * from "Contacts" where name like 'Amap%'; id | name | number | profilePicUrl | createdAt | updatedAt | email | isGroup | companyId -------+------------------+-------------------------+--------------------------------------------+----------------------------+----------------------------+-------+---------+---------- 1757 | Amapxxxxxxx | 5537###-xxx103 | https://xxxxxxx/nopicture.png | 2023-01-19 23:59:33.42+01 | 2023-01-19 23:59:33.42+01 | | t | 2 17495 | Amapxxxxxxx | 5537###xxx103 | https://xxxxxxx/nopicture.png | 2023-07-31 18:20:41.528+02 | 2023-07-31 18:20:41.528+02 | | t | 2
In contact whitout "-" I dont send any messages and receive error But i read all messages. In Contact have "-" I send messages but dont read any messages.
looks like a baileys bug, I've never gotten that error code except for the 500 error code
Using just like @davicolet configs and recurrently getting "Timed Out" This property config defaultQueryTimeoutMs: undefined, was also recommended on Baileys Discord Group, but unfortunately doesn't solve the problem. I'm also getting BAD MAC error, someone said that the "actual workaround" is to restart the whatsapp connection every 6 hours.. But didn't worked for me as well.. Is it there any solution yet?
I have the same error here
Também estou com o mesmo problema, alguma solução?
Também estou com o mesmo problema.
+1
+1
+1
Bom dia, alguma solução?
A solução é fazer tratamento em grupos. Não é bug do bayleis.
The solution is make processing in groups. not bug of bayleis.
Com certeza é um bug do Baileys...
Esse erro fica aparecendo porque o Baileys não é capaz de lidar com algo e também não mostra como tratar isso... definitivamente não é um comportamento esperado em nenhum software.
A solução é fazer tratamento em grupos. Não é bug do bayleis.
The solution is make processing in groups. not bug of bayleis.
Qual foi a solução para você?
bad decryption errors are due to some mismanagement in our libsignal, will look into them all