whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

Messages sent but never delivered to the contact

Open stefanfuchs opened this issue 1 year ago • 25 comments

Is there an existing issue for this?

  • [X] 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: https://github.com/pedroslopez/whatsapp-web.js/issues/2603 https://github.com/pedroslopez/whatsapp-web.js/issues/2554

stefanfuchs avatar Nov 28 '23 20:11 stefanfuchs

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

daveckw avatar Nov 29 '23 09:11 daveckw

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

JoseFortunato avatar Nov 30 '23 20:11 JoseFortunato

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 avatar Dec 01 '23 11:12 alechkos

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.

stefanfuchs avatar Dec 01 '23 17:12 stefanfuchs

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...

JoseFortunato avatar Dec 01 '23 20:12 JoseFortunato

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 avatar Dec 01 '23 20:12 stefanfuchs

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.

stefanfuchs avatar Dec 01 '23 20:12 stefanfuchs

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

daveckw avatar Dec 01 '23 22:12 daveckw

Hi, someone solved the problem?

JoseFortunato avatar Dec 06 '23 17:12 JoseFortunato

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();

devluinix avatar Dec 11 '23 18:12 devluinix

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

stefanfuchs avatar Dec 11 '23 18:12 stefanfuchs

@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

devluinix avatar Dec 11 '23 19:12 devluinix

@stefanfuchs, @daveckw, @JoseFortunato

Is this helpful?

alechkos avatar Dec 13 '23 15:12 alechkos

@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.

stefanfuchs avatar Dec 14 '23 03:12 stefanfuchs

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.

daveckw avatar Dec 14 '23 03:12 daveckw

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

stefanfuchs avatar Dec 14 '23 03:12 stefanfuchs

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.

JoseFortunato avatar Dec 14 '23 13:12 JoseFortunato

@daveckw Does this apply when working locally?

creskopper avatar Dec 15 '23 23:12 creskopper

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

MUHESI avatar Jan 23 '24 10:01 MUHESI

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.

daveckw avatar Jan 24 '24 03:01 daveckw

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.

MUHESI avatar Jan 24 '24 03:01 MUHESI

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

madhu441 avatar Jan 25 '24 07:01 madhu441

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

RAKESHSUVIDYA avatar May 12 '24 17:05 RAKESHSUVIDYA

@daveckw Does this apply when working locally?

Im having this same issue but Im working locally and I have space.

And unlike what you guys experienced, with me it happens from the first message, it doesn't need to be running for a while for the problem to occur.

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

Im running this on ubuntu with no problems to generate QR

gustavobotti avatar Jun 26 '24 20:06 gustavobotti

Honestly our support team is so sick of this issue - not to do with this package but the whatsapp api.

The webhooks dont return why the message was sent but not delivered, so all we know is that it was sent. This usually happens when a persons cell does not have data connection at the time of sending the message - in africa this is common! Some people turn their data off to save it.

Honestly you would think a multibillion dollar company could make this work properly.

gregg-cbs avatar Jul 04 '24 12:07 gregg-cbs