WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
3.87k stars 1.32k forks source link

[BUG] Frequent web socket closed #883

Closed oscarguindzberg closed 4 months ago

oscarguindzberg commented 4 months ago

Describe the bug I have a server with 15 connected whatsapp users.
WebSockets are closed from time to time. This callback is executed: https://github.com/WhiskeySockets/Baileys/blob/76d2a9d759c31e4b2346fb2f02ec572f4d4c0437/src/Socket/socket.ts#L584 Then baileys generates a 'connection.update' event where connection === 'close'

lastDisconnect: {
  error: Error: Connection Terminated
      at WebSocketClient.<anonymous> (/node_modules/myVersionOfBaileys/baileys/lib/Socket/socket.js:459:30)
      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 WebSocket.emitClose (/node_modules/ws/lib/websocket.js:265:10)
      at TLSSocket.socketOnClose (/node_modules/ws/lib/websocket.js:1289:15)
      at TLSSocket.emit (node:events:530:35)
      at node:net:337:12
      at TCP.done (node:_tls_wrap:657:7) {
    data: null,
    isBoom: true,
    isServer: false,
    output: [Object]
  },
  date: 2024-06-14T05:04:58.648Z
}

After the websocket is closed, I do an automatic reconnection and it works fine.

To Reproduce Steps to reproduce the behavior: 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):

Additional context Using baileys v6.7.5

oscarguindzberg commented 4 months ago

Maybe related https://github.com/WhiskeySockets/Baileys/issues/884

oscarguindzberg commented 4 months ago

I don't understand why was the issue closed.

SheIITear commented 4 months ago

You spammed 7 issues with basically same information. Also this is normal behaviour. You can observe whatsapp web and it will reconnect every now and then also.

oscarguindzberg commented 4 months ago

I created 6 issues, some look similar to others, but each one is different. Error msg is different or a different exception is thrown, etc. On each issue I included links to other issues that may be related.

About this issue in particular: Does whatsapp web reconnect every now and then because it decides to do so? In this particular case, it seems the server is closing the connection.