Skip to content

[Bug] WhatsApp connection repeatedly fails with status 440 'Stream Errored (conflict)' #9094

@nikolasdehor

Description

@nikolasdehor

Description

WhatsApp connections are repeatedly failing with status 440 conflict errors, indicating multiple simultaneous sessions attempting to connect to the same WhatsApp account.

Problem

78 occurrences of connection closed with status 440 conflict errors have been observed during normal operation.

Error Message

Web connection closed (status 440). Retry 1/12 in 2.XXs… (status=440 Unknown Stream Errored (conflict))

Root Cause Hypothesis

Multiple WhatsApp sessions are active simultaneously, creating conflicts:

  • OpenClaw gateway's WhatsApp integration attempting to connect
  • wacli attempting to connect to the same account
  • Multiple QR code scans creating competing sessions

This is consistent with WhatsApp Web's limitation of one active session per account at a time (unless using multi-device mode correctly).

Impact

  • Users experience repeated connection failures
  • Unreliable WhatsApp message delivery through OpenClaw
  • Users must fall back to wacli authentication when OpenClaw WhatsApp integration fails
  • Service interruptions during the retry cycle (up to 12 retries)

Environment

  • OpenClaw Version: 2026.2.2-3
  • Platform: macOS
  • Baileys Version: 7.0.0-rc.9
  • WhatsApp Integration: Baileys library

Logs Pattern

The logs show a consistent pattern of:

  1. Connection attempt
  2. Status 440 conflict error
  3. Retry with exponential backoff
  4. Repeated failures across multiple retry attempts

Reproduction Steps

  1. Start OpenClaw gateway with WhatsApp channel configured
  2. Scan QR code to link WhatsApp account
  3. While OpenClaw is connected, attempt to use wacli with the same account
  4. Observe status 440 conflicts in OpenClaw logs

OR

  1. Have OpenClaw gateway running with active WhatsApp session
  2. Scan QR code again without disconnecting previous session
  3. Observe status 440 conflicts

Expected Behavior

  • OpenClaw should detect existing session conflicts
  • Clear error message indicating another session is active
  • Graceful handling with user-friendly guidance
  • Automatic session cleanup when appropriate

Actual Behavior

  • Connection repeatedly fails with cryptic status 440 errors
  • No clear indication of the conflict cause
  • Continuous retry attempts despite fundamental conflict

Suggested Fix

  1. Implement session conflict detection: Before attempting connection, check for existing active sessions
  2. Mutual exclusion: Ensure OpenClaw and wacli cannot simultaneously lock the same WhatsApp account
  3. Clear error messaging: When conflict detected, show actionable error: "Another WhatsApp session is active. Please disconnect other sessions before connecting."
  4. Session management: Provide CLI command to forcefully disconnect existing sessions
  5. Health check: Add endpoint to verify WhatsApp session status and conflicts

Related Issues

Labels

bug, whatsapp, priority:high, baileys

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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