Baileys: Error 428 - Precondition Required[BUG]

Describe the bug When trying to send an image I get error 428.

To Reproduce Steps to reproduce the behavior:

  1. Created a new connection
  2. Schedule a cron-job every 12 hours, to run an image sending function

Expected behavior Send the image.

Environment (please complete the following information):

  • Is this on a server? Yes

  • What do your connectOptions look like? image

  • Do you have multiple clients on the same IP? No

  • Are you using a proxy? No

Additional context My function is: image

The error is: image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

setting syncFullHistory: false in makeWASocket and waited for 30 seconds before sending a first message resolved my issue.

  setTimeout(async () => {
    const jid = '919912345678@s.whatsapp.net';

    await socket.presenceSubscribe(jid);
    await delay(500);
  
    await socket.sendPresenceUpdate('composing', jid);
    await delay(2000);
  
    await socket.sendPresenceUpdate('paused', jid);
    await socket.sendMessage(jid, { text: 'Hello from Whatsapp' });
  }, 30000);

Nada que hacer, la solución es simplemente reiniciar la conexión del socket.

¿Cómo manejamos el reinicio con el error 428?

Ini terjadi ketika Anda menghabiskan waktu berjam-jam tanpa menerima peristiwa apa pun, misalnya: tanpa menerima pesan dalam waktu lama

hello bro, what if the status code is 408 when using conn.profilePictureUrl

This happens when you spend hours without receiving any events, for example: without receiving messages for a long time

For this type of logout reason you need to restart the socket

I handle reconnection on update event: Screenshot_20231016-215211_GitHub~2.png