Skip to content

[GOWS] Expose whatsmeow KeepAlive interval via env — sessions flap behind idle-socket-reaping proxies #2167

Description

@chengkangzai

Problem

Running the GOWS engine (WAHA 2026.7.1, Core) with sessions behind residential/rotating HTTP proxies, sessions flap STARTINGWORKING continuously on Keepalive timed out, and real operations fail during the flap windows.

Representative loop for a single session, repeating roughly every ~35s:

WARN  [Session/<s>/Client] Keepalive timed out {"engine":"gows"}
ERROR [Session/<s>/Client/Socket] Error reading from websocket: failed to get reader: failed to read frame header: EOF {"engine":"gows"}
INFO  [Session/<s>/Client] Successfully authenticated {"engine":"gows"}

During a flap window, sends fail with:

500 ... failed to get device list: failed to send usync query: info query timed out

and the flap dominates session.status webhook volume. It is not a ban and not a creds problem — the session re-authenticates every cycle.

Root cause

whatsmeow pings on a randomised interval KeepAliveIntervalMin = 20s .. KeepAliveIntervalMax = 30s (keepalive.go). Many residential/rotating proxy exits reap an idle CONNECT tunnel well before 20s (~10–15s in our measurements). So the keepalive ping almost always lands on an already-dead socket → timeout → reconnect → repeat.

whatsmeow already supports the fix: KeepAliveIntervalMin / KeepAliveIntervalMax are exported package-level vars (not consts), so a consumer can lower them (e.g. ~8s) to beat the reap. But the WAHA gows binary exposes no way to set them.

Verification that the knob is currently missing

The /app/gows binary reads GOWS_* env vars, but only history-sync ones — none for keepalive:

GOWS_DEVICE_HISTORY_SYNC_*        (22 vars)
GOWS_DEVICE_REQUIRE_FULL_SYNC
GOWS_STATUS_PARTICIPANTS_BATCH_SIZE

and it is launched with only --socket. The KeepAliveInterval* symbols are present in the binary (the whatsmeow vars themselves) but there is no env/flag path to set them.

Request

Expose the whatsmeow keepalive interval via env — the GOWS_* env plumbing already exists, so this should be a small addition — e.g.:

GOWS_KEEPALIVE_INTERVAL_MIN_SEC=8
GOWS_KEEPALIVE_INTERVAL_MAX_SEC=12

setting whatsmeow.KeepAliveIntervalMin / KeepAliveIntervalMax at gows startup. This lets proxy users keep the tunnel warm without patching/forking. Per-session would be a bonus but a global env is enough.

Not a duplicate of #1880

#1880 is about sessions dropping after a month and is answered by the presence API. This is the sub-30s socket keepalive ping vs proxy idle-reap — a different layer.

Environment: WAHA 2026.7.1 (Core), engine GOWS, sessions behind a residential HTTP proxy.

patron:PLUS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions