towerops/lib/towerops_web/channels
Graham McIntire 303c64ceae fix: set last_heartbeat_db_update on agent join to fix offline detection (#142)
When an agent joins, we update last_seen_at in the database but don't set
last_heartbeat_db_update in the socket. This causes the heartbeat throttling
logic to be out of sync:

- On join: DB updated, but last_heartbeat_db_update not set (nil)
- First heartbeat: Updates DB again because last_heartbeat_db_update is nil
- Subsequent heartbeats: Check if >30s since last DB update
- Problem: last_heartbeat_db_update tracks the first heartbeat, not the join DB update

This manifests when Phoenix recompiles during development - the channel process
continues running with old socket assigns, and if last_heartbeat_db_update is
recent, heartbeats won't update the DB. After 10+ minutes without DB updates,
the agent appears offline even though it's still connected.

Fix: Set last_heartbeat_db_update when we update the DB on join, so the
throttling logic accurately tracks the most recent DB update.

Reviewed-on: graham/towerops-web#142
2026-03-24 12:19:13 -05:00
..
agent_channel.ex fix: set last_heartbeat_db_update on agent join to fix offline detection (#142) 2026-03-24 12:19:13 -05:00
agent_socket.ex Add Dialyzer typespecs to WebSocket agent code and Agents context 2026-01-17 10:37:27 -06:00
mobile_channel.ex add mobile app websocket channel and improve QR linking UX 2026-03-13 17:28:36 -05:00
mobile_socket.ex add mobile app websocket channel and improve QR linking UX 2026-03-13 17:28:36 -05:00