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: open
  • Created 8 months ago
  • Comments: 16 (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?

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