✨ feat: stream_measurements sends __ping__ every 60 s (keep-alive) #164
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/ws-ping"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The server declines STOMP-level heart-beating, so the SPA keeps the stream alive by sending the literal text
__ping__on the WebSocket every 60 s (no-op for the server —docs/energy.comwatt.com/websocket-realtime.md). The client now mirrors that: a time-based check in the consume loop, independent of traffic. This also fixes a latent crash:ws.recv()on a socket silent for longer than the client timeout raisedWebSocketTimeoutExceptionstraight out of the generator; timeouts now just wake the ping check. A__ping__that hits a dead socket ends the stream cleanly instead of leaking the raw websocket-client exception.Evidence
WebSocketTimeoutException; no keep-alive was ever sent.__ping__sent after 60 s of silence (exactly once), no ping before 60 s, ping still sent while frames flow (time-based), dead-socket-during-ping ends the stream with DISCONNECT teardown attempted;pytest= 211 passed;mypyclean.Merge Danger
Door: two-way — consume-loop only; revert restores the old silence-kills-stream behavior.
Blast Radius: low — streams now send one 7-byte text frame per minute; silent streams that used to die now survive. Handshake and frame parsing unchanged.
Closes half of #101 (the
/app/streaming/stopteardown follows as a stacked PR)WIP: ✨ feat: stream_measurements sends __ping__ every 60 s (keep-alive)to ✨ feat: stream_measurements sends __ping__ every 60 s (keep-alive)