YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
Relax events websocket ping cadence (#4043)
Louis Beaumontf6e5d6f1b860
diff --git a/crates/screenpipe-engine/src/routes/websocket.rs b/crates/screenpipe-engine/src/routes/websocket.rsindex 69bba6097..46aa3df87 100644--- a/crates/screenpipe-engine/src/routes/websocket.rs+++ b/crates/screenpipe-engine/src/routes/websocket.rs@@ -34,6 +34,7 @@ use super::meetings::{resolve_meeting_status_from, MeetingStatusResponse};/// Maximum number of concurrent WebSocket connections allowed./// This prevents file descriptor exhaustion from too many open connections.pub(crate) const MAX_WEBSOCKET_CONNECTIONS: usize = 100;+pub(crate) const EVENTS_WEBSOCKET_PING_INTERVAL: Duration = Duration::from_secs(15);/// Guard that decrements the WebSocket connection counter when dropped./// This ensures the counter is always decremented, even on panics or early returns.@@ -143,7 +144,7 @@ async fn handle_socket(socket: WebSocket, query: Query<EventsQuery>, _guard: WsC}}}- _ = tokio::time::sleep(Duration::from_secs(1)) => {+ _ = tokio::time::sleep(EVENTS_WEBSOCKET_PING_INTERVAL) => {let _ = sender.send(Message::Ping(vec![])).await;}}@@ -317,3 +318,13 @@ async fn handle_metrics_socket(debug!("Metrics WebSocket connection closed");}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn events_websocket_ping_interval_is_not_busy() {+ assert_eq!(EVENTS_WEBSOCKET_PING_INTERVAL, Duration::from_secs(15));+ }+}