venom: Session saving problem
Description
The session is created, but when the script is restarted, the session does not rise and asks to rescanQr
Environment
- Venom version(s): [4.0.5]
- Browser: [default venom]
- OS: [linux ubuntu 20.04]
- Node version: [Node 12.22.5]
Steps to Reproduce
- [Session creation]
- [Reboot script]
Log Output
Session creation
info: [79297401290] Initializing browser wss...
info: [79297401290] Browser successfully opened
info: [79297401290] checking headless...
info: [79297401290] headless option is active, browser hidden
info: [79297401290] Checking page...
info: [79297401290] Page successfully accessed
- [instance: 79297401290]: Waiting page load
- [instance: 79297401290]: Checking is logged...
- [instance: 79297401290]: Waiting for QRCode Scan...
- [instance: 79297401290]: Waiting for QRCode Scan: Attempt 1
- [instance: 79297401290]: Waiting for QRCode Scan: Attempt 2
- [instance: 79297401290]: Checking QRCode status...
- [instance: 79297401290]: QRCode Success
- [instance: 79297401290]: Checking phone is connected...
- [instance: 79297401290]: Connected
Reboot script
info: [79297401290] Initializing browser wss...
info: [79297401290] Browser successfully opened
info: [79297401290] checking headless...
info: [79297401290] headless option is active, browser hidden
info: [79297401290] Checking page...
info: [79297401290] Page successfully accessed
- [instance: 79297401290]: Waiting page load
- [instance: 79297401290]: Checking is logged...
- [instance: 79297401290]: Waiting for QRCode Scan...
- [instance: 79297401290]: Waiting for QRCode Scan: Attempt 1
- [instance: 79297401290]: Page Closed
- [instance: 79297401290]: Checking QRCode status...
- [instance: 79297401290]: Failed to authenticate
- [instance: 79297401290]: Unknow error
If relevant, paste all of your Log Output
Your Code
const venom = require('venom-bot');
venom
.create({
session: 'session-name', //name of session
multidevice: false // for version not multidevice use false.(default: true)
})
.then((client) => start(client))
.catch((erro) => {
console.log(erro);
});
function start(client) {
client.onMessage((message) => {
if (message.body === 'Hi' && message.isGroupMsg === false) {
client
.sendText(message.from, 'Welcome Venom 🕷')
.then((result) => {
console.log('Result: ', result); //return object success
})
.catch((erro) => {
console.error('Error when sending: ', erro); //return object error
});
}
});
}
Additional context / Screenshot
Add any other context about the problem here. If applicable, add screenshots to help explain.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17
For multi device beta, the following config created the tokens for me automatically:
Setting
folderNameToken,mkdirFolderTokenandcreatePathFileTokenwere the magic config that created a large session specific token folder that was reused when restarting the server.For non multi device, you have to save it manually using
client.getSessionTokenBrowser()and then read it back and pass it as an option tocreateasbrowserSessionToken.The following works for both multi device and non:
you can save the session token manually. See here in this script! The comments are in Portuguese, but you can translate the page. OK!?
https://github.com/jrCleber/bot-venom-firebase/blob/main/app/bot.ts
Project developers rarely help us.