pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.07k stars 3.59k forks source link

client.sendMessage() not working. #3262

Closed UltimoDragao closed 2 weeks ago

UltimoDragao commented 2 weeks ago

Is there an existing issue for this?

Describe the bug

I have an simple API in an AWS ec2 server, running on ubuntu with the most recent version of node. When I first start the API and log the sessions, the first few messages are being sent normally, but after that, the sendMessage() function has no return or action.

Here's my client declaration:

private composeClientOptions(sessionName: string): ClientOptions { const wwebVersion = '2.3000.1013767544'; return { restartOnAuthFail: true, webVersion: wwebVersion, webVersionCache: { type: 'remote', remotePath: https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html, }, puppeteer: { headless: true, args: [ '--aggressive-cache-discard', '--disable-accelerated-2d-canvas', '--disable-application-cache', '--disable-background-networking', '--disable-cache', '--disable-client-side-phishing-detection', '--disable-component-update', '--disable-default-apps', '--disable-dev-shm-usage', '--disable-extensions', '--disable-gpu', '--disable-offer-store-unmasked-wallet-cards', '--disable-offline-load-stale-cache', '--disable-popup-blocking', '--disable-setuid-sandbox', '--disable-speech-api', '--disable-sync', '--disable-translate', '--disable-web-security', '--disk-cache-size=0', '--hide-scrollbars', '--ignore-certificate-errors', '--ignore-ssl-errors', '--metrics-recording-only', '--mute-audio', '--no-default-browser-check', '--no-first-run', '--no-pings', '--no-sandbox', '--no-zygote', '--password-store=basic', '--safebrowsing-disable-auto-update', // '--single-process', '--use-mock-keychain', ], }, authStrategy: new LocalAuth({ clientId: sessionName }), }; }

Here's my sendMessage function being called:

private async sendMessage( sessionIndex: number, number: string, message: string, sender: string, instance: string ) { try { await sessions[sessionIndex].client.sendMessage( composeNewNumber(number), message ); //It never gets past this point. The message is not sent, no error is thrown or anything, it just gets stuck in here. await this.saveMessageToLog(sender, message, number, instance); console.log( getCurrentDateConsole() + 'Mensagem da instância ' + instance + ' enviada com sucesso.' ); } catch (error) { console.log(error); } }

Notice that every other routine is working properly, just the send message one is not working.

Expected behavior

Message should be sent.

Steps to Reproduce the Bug or Issue

  1. Receive message send request
  2. Try to send message using client.sendMessage() function
  3. Message doesn't get sent

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

AWS EC2 instance running with Ubuntu Whatsapp-web version is the latest Node version 22.7

Additional context

No response

moshe-boostapp commented 1 week ago

same issue here!

UltimoDragao commented 1 week ago

another one with the same problem. I didn't understood why my issue was closed, but since I could solve it in another way, I let it go. But it could be a real, big problem. Could you reopen it?