orkestral / venom

Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
https://orkestral.io
Apache License 2.0
6.03k stars 1.18k forks source link

Tokens are not saved using browserWS #1404

Closed c0nf1ck closed 2 years ago

c0nf1ck commented 2 years ago

Description

As mentioned in #1292 , when using the browserWS option, the token to automatically reconnect are not saved

Environment

Steps to Reproduce

  1. docker run -d --restart unless-stopped -p 5000:3000 -e "MAX_CONCURRENT_SESSIONS=1" browserless/chrome:latest

  2. const start = async (session) => {
    logger.info(`Creating whatsapp session...`)
    
    const browserWS = process.env.NODE_ENV === "production" ? "ws://localhost:5000" : null
    
    return venom.create({ 
        session, 
        multidevice: true,
        headless: true,
        useChrome: true,
        browserWS,
        autoClose: false,
        disableSpins: true,
        disableWelcome: true,
        folderNameToken: path.resolve(root.path, 'data/wa/tokens/'),
        logQR: true,
        updatesLog: false,
        logger
     }).then(async (client) => {
        logger.info(`Whatsapp session available`)
        waClient = client
     })
    }
  3. There's no token saved.

Log Output

If relevant, paste all of your Log Output

Your Code

If relevant, paste all of your challenge code in here

Additional context / Screenshot

Add any other context about the problem here. If applicable, add screenshots to help explain.

AlexsandroZanella2 commented 2 years ago

just use this code in create:

client.getSessionTokenBrowser().then((result) => { require('fs').writeFile("./tokens/"+client.session+".data.json", JSON.stringify(result), function(err) { if(err) return console.error(err); }); }).catch((error) => { console.error(error)});