The gateway now ships in the
praisonai-bot package. praisonai serve gateway still works exactly as documented here; for a standalone install see praisonai-bot Migration.Quick Start
How It Works
The gateway emits aPING on each interval; any inbound frame (a PONG, a peer PING, or a normal message) refreshes last_activity. A silent peer misses beats until the reaper closes it.
| Piece | Owner | Role |
|---|---|---|
EventType.PING / EventType.PONG | Protocol | Wire frame both peers agree on |
LivenessPolicy.evaluate(last_activity, now) | Core (pure) | Returns KEEP or REAP |
| Gateway reaper task | Wrapper server | Emits PING, calls evaluate, closes with LIVENESS_TIMEOUT |
| Client watchdog | Reference client | Sends PING, force-reconnects on silence |
GatewayCloseCode.LIVENESS_TIMEOUT | Protocol | Typed close code the client can recognise |
now > last_activity + interval_seconds × missed_beats_before_reap. Setting enabled=False (the default) makes evaluate always return KEEP, so upgrading changes nothing.
Configuration Options
LivenessConfig is the user-facing config; to_policy() bridges it to the pure LivenessPolicy the reaper consumes.
Full field, type, and default reference
Common Patterns
Pick a cadence from the peer’s network profile — the default is a no-op until you turn it on.Disabled (default)
Mobile / NAT peers
Aggressive reaping for high-turnover realtime
Best Practices
Leave it off until presence lies
Leave it off until presence lies
Default is
enabled=False — behaviour is unchanged. Only enable it when presence stays online after a peer vanishes.Honour the advertised interval on custom clients
Honour the advertised interval on custom clients
The server advertises
heartbeat_ms; the reference client’s watchdog trips at ~2× that. If you build your own client, honour the advertised value so both sides derive the same window from reap_deadline / interval_seconds.Treat LIVENESS_TIMEOUT as expected
Treat LIVENESS_TIMEOUT as expected
Treat this close code as expected. Reconnect and resume — don’t surface it as a fatal error to the user.
Related
Reliability Preset
Related resilience knobs
Session Continuity
What survives a reap

