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

Messages sent but never delivered to the contact #2654

Open
1 task done
stefanfuchs opened this issue Nov 28, 2023 · 23 comments
Open
1 task done

Messages sent but never delivered to the contact #2654

stefanfuchs opened this issue Nov 28, 2023 · 23 comments
Labels
bug Something isn't working

Comments

@stefanfuchs
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm having a weird issue: when the whatsapp-web.js client is online for some time, some messages that are sent are never actually delivered to the contact. They stay with one gray "tick" forever.

The most weird thing about this bug is that these messages appear on the mobile app with 1 gray tick as well, but never get delivered.

Sometimes clearing the whatsapp session works, but only for some time. It has to be done again and again.

This issue is happening consistently across multiple numbers, and i've been scratching my head a lot trying to figure out what's happening.

Expected behavior

The messages that are sent should be delivered to the contacts after some time.

Steps to Reproduce the Bug or Issue

  1. Start the whatsapp-web.js client, and use for some time (e.g. 1 or 2 hours).
  2. Send a message via the sendMessage method.
  3. Some contacts don't actually receive these messages, they stay with one gray "tick" forever. No delivered or read events are generated by the whatsapp client.

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

OS: Docker + Alpine 3.15
Phone OS: Android
whatsapp-web.js version: 1.23.1
WhatsApp Web version [run await client.getWWebVersion()]: 2.2350.52
Node.js Version: 16.20.2-r0

Additional context

Related issues, which might ou might not be the same problem:
#2603
#2554

@stefanfuchs stefanfuchs added the bug Something isn't working label Nov 28, 2023
@daveckw
Copy link

daveckw commented Nov 29, 2023

I am facing the same issue. Reconnect sometimes solved the issue but there is no indication when it has the issue

@JoseFortunato
Copy link

I am facing the same issue. When i reconnect it works for some time....

@alechkos
Copy link
Collaborator

alechkos commented Dec 1, 2023

There is no issues with sendMessage method in your context.
More likely that the problem is in your code, maybe with handling asynchronous methods.
Also you should keep the client active, e.g. by calling some library method approximately every 4 hours.

@alechkos alechkos closed this as completed Dec 1, 2023
@stefanfuchs
Copy link
Contributor Author

stefanfuchs commented Dec 1, 2023

I've been using the lib for 3 years now, and only recently these kinds of problems started. I'ts most likely a bug in whatsapp itself, and the annoying part is that it happens randomly after using the lib normally for some time.

And yes, I'm using the lib very frequently to send messages - with multiple numbers - therefore it's not a problem of keeping the client active. In fact, the more messages are sent, the bigger the probability of this problem occuring.

@alechkos alechkos added the whatsapp bug A bug in WhatsApp Web, issues under this label are to just inform the user on info label Dec 1, 2023
@alechkos alechkos reopened this Dec 1, 2023
@JoseFortunato
Copy link

I've been using the lib for 3 years now, and only recently these kinds of problems started. I'ts most likely a bug in whatsapp itself, and the annoying part is that it happens randomly after using the lib normally for some time.

And yes, I'm using the lib very frequently to send messages - with multiple numbers - therefore it's not a problem of keeping the client active. In fact, the more messages are sent, the bigger the probability of this problem occuring.

Same here...

@stefanfuchs
Copy link
Contributor Author

And it's very strange because these messages even show up in the whatsapp app in the mobile phone... but they stay forever with one gray tick, never delivered. That's why it seems like a bug in whatsapp itself.

@stefanfuchs
Copy link
Contributor Author

I am trying to update the chromium / puppeteer versions, because I saw the version used by the lib is more than 1 year old... and that might be the problem. Will have to try and see if it works.

@daveckw
Copy link

daveckw commented Dec 1, 2023

Yes. It has become more serious lately (more frequent).

@JoseFortunato
Copy link

Hi, someone solved the problem?

@devluinix
Copy link

devluinix commented Dec 11, 2023

Same problem for me, try doing a LOOP to restart the application every 1 hour. Always reconnecting the session like this, because apparently Whatsapp is putting the session in the span list

USING: client.resetState();

@stefanfuchs
Copy link
Contributor Author

@devluinix when reseting the state like this, the qr code must be read again?

@devluinix
Copy link

@stefanfuchs no need read again.

My Client

path = 'mysession';

global.client = new Client({
      authStrategy: new LocalAuth({ clientId: path }),
      puppeteer: { 
	     headless: true,
         args: ['--no-sandbox'],
	  }
   });

Recomended too:

  • Random 20 seconds
    client.sendPresenceAvailable() ONLINE
    client.sendPresenceUnavailable() OFFLINE

CODE

let delayVerify = 20000; //20s
   setInterval(() => {
		 if (Math.random() < 0.8) {
			try { client.sendPresenceAvailable(); } catch (e) { console.log("Erro: sendPresenceAvailable"); } 
		 } else {
			try { client.sendPresenceUnavailable(); } catch (e) { console.log("Erro: sendPresenceUnavailable"); }
		 }
   }, delayVerify);

To simulate a human

@alechkos alechkos removed the whatsapp bug A bug in WhatsApp Web, issues under this label are to just inform the user on info label Dec 13, 2023
@alechkos
Copy link
Collaborator

@stefanfuchs, @daveckw, @JoseFortunato

Is this helpful?

@stefanfuchs
Copy link
Contributor Author

@alechkos it seems to be helping, I tested your solution for one day so far.

I'm using resetState() when at least 10 messages aren't delivered, without reseting the client. But when 15 messages are pending, I reset the whole app. resetState seems to be helping with the delivery of the messages.

Also, I'm using your code of sending the presence available/unavailable.

@daveckw
Copy link

daveckw commented Dec 14, 2023

Dear all, thank you for all the suggestions. I found out what the issue was on my side. My whatsapp web js is running on Google Cloud Server VM. The storage of the disk was utilised up till 90% most of the time and the issues above started happening. I upgraded the storage to 30GB (was 10GB before) and everything is working smoothly now. There are no more disconnection or unsent messages.

@stefanfuchs
Copy link
Contributor Author

@daveckw interesting... I'm using amazon ECS here. I'll try to increase the disk space in the tasks, see if it helps.

@JoseFortunato
Copy link

Dear all, the same here. The storage of the disk was utilised up till 99% on aws EC2, i increased disk size and everything is working smoothly now.

@creskopper
Copy link

@daveckw Does this apply when working locally?

@MUHESI
Copy link

MUHESI commented Jan 23, 2024

interestingly, the solution has been found,
By the way I am also exploring this interesting library but I want to know:
can they make a map of more than 1000 contacts who will receive messages?
I've read WhatsApp's policy, which forbids sending mass messages.
Can't this kind of use become a problem for WhatsApp?

@daveckw @stefanfuchs

@daveckw
Copy link

daveckw commented Jan 24, 2024

interestingly, the solution has been found, By the way I am also exploring this interesting library but I want to know: can they make a map of more than 1000 contacts who will receive messages? I've read WhatsApp's policy, which forbids sending mass messages. Can't this kind of use become a problem for WhatsApp?

@daveckw @stefanfuchs

Yes. You can. However bear in mind if large number of people report Spam, your number can be banned by whatsapp.

@MUHESI
Copy link

MUHESI commented Jan 24, 2024

interestingly, the solution has been found, By the way I am also exploring this interesting library but I want to know: can they make a map of more than 1000 contacts who will receive messages? I've read WhatsApp's policy, which forbids sending mass messages. Can't this kind of use become a problem for WhatsApp?
@daveckw @stefanfuchs

Yes. You can. However bear in mind if large number of people report Spam, your number can be banned by WhatsApp.

Okay, I see, thanks for your answer. can you share your LinkedIn or Twitter (X) username, Is it possible?
we can continue to discuss there.

@madhu441
Copy link

var client = new Client({
restartOnAuthFail: true,
takeoverOnConflict: true,
takeoverTimeoutMs: 0,
puppeteer: {
handleSIGINT: false,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
'--disable-gpu'
],
executablePath: chrome_path,
},
authStrategy: new LocalAuth(
{ clientId: sender_id }
)
}
);
I am this client using on group send message response is success but not delivered why

@RAKESHSUVIDYA
Copy link

QR is not working properly in ubuntu platform. Is there anyone who can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants