Skip to content

Ghost connection: After an idle period, the socket is stuck in the ON state with wsReadyState: null. It's not performing actions like sending messages. #201734

@izofis

Description

@izofis

Issue Description

After a period of inactivity, the client appears connected but cannot send or receive messages. No disconnected event is emitted. The socket is internally frozen in a ghost [OPENING] state where the underlying WebSocket no longer exists (wsReadyState: null).

Inspecting the connection state reveals:
{ "socketState": "OPENING", "socketStream": "DISCONNECTED", "wsReadyState": null, "hasSynced": true, "connWid": null }

The only way to recover is to close and reopen the browser. This behavior does not occur in versions prior to 1.34.7.

Reproduction Steps

Initialize a client and wait for the ready event
Leave the session idle for a while (especially in Docker or behind a NAT/firewall)
Attempt to send a message — it silently fails with no error or disconnect event
Check the connection state

const info = await client.pupPage.evaluate(() => { const socket = window.require('WAWebSocketModel').Socket; const ws = socket.socket; return { socketState: socket.state, socketStream: socket.stream, wsReadyState: ws ? ws.readyState : null, hasSynced: socket.hasSynced, connWid: socket.wid ?? null, }; }); console.log(info);

Observe: socketState: "OPENING", socketStream: "DISCONNECTED", wsReadyState: null
Closing and reopening the browser resolves the issue

Environment:
whatsapp-web.js version: 1.34.7
Node.js: v20.x
Platform: Docker / Linux / NAT network

Code Sample

User Setup

WhatsApp Type
Account Type Standard
Authentication Strategy RemoteAuth
WhatsApp Web Version 0000000000
whatsapp-web.js Version 1.34.7
Environment Version
Browser Type chrome
Browser Version 0000
Phone OS Version android
Running OS Version ubuntu
Node.js Version 20x

Checklist

  • I use the latest released version of whatsapp-web.js.
  • I have searched existing issues and confirmed this is not a duplicate.
  • I have verified this is a library issue, not a problem with my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokenissued lowLow impact issuetypingsType definitions

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions