appservice: heartbeat presence every 20s to beat Synapse's 30s offline timeout (was flapping at 60s)

This commit is contained in:
prosolis
2026-07-04 10:42:55 -07:00
parent 0f82a088f9
commit a4f162d2ee

View File

@@ -18,12 +18,14 @@ import (
) )
// presenceHeartbeatInterval is how often the appservice re-asserts its online // presenceHeartbeatInterval is how often the appservice re-asserts its online
// presence. In masdevice mode the /sync long-poll refreshed presence implicitly // presence. In masdevice mode the /sync long-poll refreshed presence implicitly;
// (~30s); appservice mode has no /sync, so we push presence explicitly. Synapse // appservice mode has no /sync, so we push presence explicitly. Synapse ties
// decays an "online" user to unavailable after ~5min of no update, so a 1min tick // "online" to recent activity and force-offlines a non-syncing user ~30s after its
// keeps the bot reliably green while running — and lets it decay to offline on its // last update (SYNC_ONLINE_TIMEOUT). A slower tick makes the bot FLAP (green right
// own if the process dies without a graceful shutdown. // after each PUT, then offline until the next) — empirically observed at 60s. So we
const presenceHeartbeatInterval = time.Minute // tick well under 30s to hold it continuously green. A hard crash stops the
// heartbeat and Synapse offlines the bot within ~30s on its own.
const presenceHeartbeatInterval = 20 * time.Second
// cryptoToDeviceTypes are the to-device event types the crypto machine must see // cryptoToDeviceTypes are the to-device event types the crypto machine must see
// to establish Olm/Megolm sessions and share/receive room keys. In /sync mode // to establish Olm/Megolm sessions and share/receive room keys. In /sync mode