Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onStateChange not working Venom-Bot 5.1.0 #2789

Open
rmp1985 opened this issue Jul 23, 2024 · 0 comments
Open

onStateChange not working Venom-Bot 5.1.0 #2789

rmp1985 opened this issue Jul 23, 2024 · 0 comments
Labels
bug Something isn't working needs triage Needs avaliation

Comments

@rmp1985
Copy link

rmp1985 commented Jul 23, 2024

Description

When disconnected on Whatsapp, Venom does not trigger onStateChange

Environment

  • Venom version(s): [5.1.0]
  • Browser: [thorium-browser/stable,now 124.0.6367.218-1 amd64 [installed]]
  • OS: [Ubuntu 20.04.6 LTS]
  • Node version: [v18.18.0]

Steps to Reproduce

  1. [Connect the account and wait for SuccessChat status]
  2. [Disconnect WhatsApp account on phone]
  3. [Venom should execute onStateChange but it doesn't]

Log Output

nothing in the log

Your Code

venom
  .create(
    sessionName,
    async (base64Qrimg/*, asciiQR, attempts, urlCode*/) => {
      
      console.log(base64Qrimg)

    },
    async (statusSession/*, session*/) => {

      //statusSession return isLogged || notLogged || browserClose || qrReadSuccess || qrReadFail || autocloseCalled || desconnectedMobile || deleteToken || chatsAvailable || deviceNotConnected || serverWssNotConnected || noOpenBrowser || initBrowser || openBrowser || connectBrowserWs || initWhatsapp || erroPageWhatsapp || successPageWhatsapp || waitForLogin || waitChat || successChat          
    
      console.log(statusSession)

    },
    {
      multidevice: false, //true,//nao achei na documentacao, mas foi testado e da diferença (se mandar true ou false funciona, se nao mandar nada ai da problema)
      browserPathExecutable: '/usr/bin/thorium-shell', //'/usr/bin/thorium-shell', //'/usr/bin/chromium-browser', //'/usr/bin/google-chrome-stable', //'', // browser executable path
      folderNameToken: tokenFolder, //folder name when saving tokens
      // mkdirFolderToken: '', //folder directory tokens, just inside the venom folder, example:  { mkdirFolderToken: '/node_modules', } //will save the tokens folder in the node_modules directory
      headless: 'new', // you should no longer use boolean false or true, now use false, true or 'new' learn more https://developer.chrome.com/articles/new-headless/
      devtools: false, // Open devtools by default
      debug: false, // Opens a debug session
      logQR: false, //true, // Logs QR automatically in terminal
      // browserWS: '', // If u want to use browserWSEndpoint
      browserArgs: ['--no-sandbox', 
                    '--disable-setuid-sandbox', 
                    '--disable-dev-shm-usage', 
                    '--disable-gpu',
                    '--window-size=640,480',
                    '--disable-infobars',
                    '--disable-extensions',
                   ], // Original parameters  ---Parameters to be added into the chrome browser instance
      // addBrowserArgs: [''], // Add broserArgs without overwriting the project's original
      // puppeteerOptions: {}, // Will be passed to puppeteer.launch
      disableSpins: true, // Will disable Spinnies animation, useful for containers (docker) for a better log
      disableWelcome: true, // Will disable the welcoming message which appears in the beginning
      updatesLog: false, //true, // Logs info updates automatically in terminal
      autoClose: 60000, //60000, // Automatically closes the venom-bot only when scanning the QR code (default 60 seconds, if you want to turn it off, assign 0 or false)
      // createPathFileToken: true, //false, // creates a folder when inserting an object in the client's browser, to work it is necessary to pass the parameters in the function create browserSessionToken
      // addProxy: [''], // Add proxy server exemple : [e1.p.webshare.io:01, e1.p.webshare.io:01]
      // userProxy: '', // Proxy login username
      // userPass: '' // Proxy password
    },
    // BrowserInstance
    (browser, waPage) => {
      // console.log('Browser PID:', browser.process().pid);
      // waPage.screenshot({ path: 'screenshot.png' });
    }
  )
  .then((client) => {

    start(client, sessionName);    

  })
  .catch(async (erro) => {

    console.error(erro)

  });

start = (client, sessionName) => {

  client.onStateChange((state) => {
    console.log('State changed: ', state);
  });
}

Detail: statusSession also does not trigger console.log

@rmp1985 rmp1985 added bug Something isn't working needs triage Needs avaliation labels Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Needs avaliation
Projects
None yet
Development

No branches or pull requests

1 participant