WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API

Home Page:https://baileys.whiskeysockets.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Frequent CB:stream:error

oscarguindzberg opened this issue · comments

Describe the bug
I have a server with 15 connected whatsapp users.
This callback is excecuted from time to time:

end(new Boom(`Stream Errored (${reason})`, { statusCode, data: node }))

This is printed on the log:
{"level":50,"time":1718364323152,"pid":30479,"hostname":"ip-xxx-xxx-xxx-xxxx","node":{"tag":"stream:error","attrs":{"code":"503"}},"msg":"stream errored out"}

Code 503 is DisconnectReason.unavailableService

Then baileys generates a 'connection.update' event where connection === 'close'

  lastDisconnect: {
    error: Error: Stream Errored (restart required)
        at WebSocketClient.<anonymous> (/node_modules/MyVersionOfBaileys/baileys/lib/Socket/socket.js:524:13)
        at WebSocketClient.emit (node:events:518:28)
        at /node_modules/MyVersionOfBaileys/baileys/lib/Socket/socket.js:241:35
        at Object.decodeFrame (/node_modules/MyVersionOfBaileys/baileys/lib/Utils/noise-handler.js:149:17)
        at WebSocketClient.onMessageReceived (/node_modules/MyVersionOfBaileys/baileys/lib/Socket/socket.js:217:15)
        at WebSocketClient.emit (node:events:518:28)
        at WebSocket.<anonymous> (/node_modules/MyVersionOfBaileys/baileys/lib/Socket/Client/web-socket-client.js:46:100)
        at WebSocket.emit (node:events:518:28)
        at Receiver.receiverOnMessage (/node_modules/ws/lib/websocket.js:1209:20)
        at Receiver.emit (node:events:518:28) {
      data: [Object],
      isBoom: true,
      isServer: true,
      output: [Object]
    },

To Reproduce
Don't know how to reproduce, it happens from time to time on a server with 15 connected whatsapp users.

Expected behavior
No errors on the log

Environment (please complete the following information):

  • Is this on a server? yes
  • What do your connectOptions look like?
         const { version, isLatest } = await fetchLatestBaileysVersion()
        const { state, saveCreds } = await useMultiFileAuthState('myPath')
    const msgRetryCounterCache = new NodeCache()

        async function getMessage(key)  {
            if(store) {
                const msg = await store.loadMessage(key.remoteJid, key.id)
                return msg?.message || undefined
            }
            // only if store is present
            return proto.Message.fromObject({})
        }

 makeWASocket({
            version,
            logger,
            printQRInTerminal: false,
            mobile: false,
            auth: {
                creds: state.creds,
                keys: makeCacheableSignalKeyStore(state.keys, logger),
            },
            msgRetryCounterCache,
            generateHighQualityLinkPreview: true,
            // ignore broadcast and newsletter messages
            shouldIgnoreJid: jid => !jid || isJidBroadcast(jid) || isJidNewsletter(jid),
            // implement to handle retries & poll updates
            getMessage,
            shouldSyncHistoryMessage: () => true,
            markOnlineOnConnect: false
        })
  • Do you have multiple clients on the same IP? yes, 15 clients
  • Are you using a proxy? no

Additional context
Using baileys v6.7.5

I don't understand why was the issue closed.