From 9502d4c207e2cb668110f6969e6dbf81f64cdecc Mon Sep 17 00:00:00 2001 From: Frauk Date: Tue, 19 Nov 2024 11:23:25 +0000 Subject: [PATCH 1/2] close websocket when keepalive are no longer received --- src/websocket/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/websocket/mod.rs b/src/websocket/mod.rs index c279b1f28..888222f49 100644 --- a/src/websocket/mod.rs +++ b/src/websocket/mod.rs @@ -201,6 +201,14 @@ impl SignalWebSocketProcess { futures::select! { _ = ka_interval.tick().fuse() => { use prost::Message; + if self.outgoing_keep_alive_set.len() > 6 { + tracing::warn!("Websocket will be closed due to failed keepalives."); + if let Err(e) = self.ws.close(reqwest_websocket::CloseCode::Away, None).await { + tracing::debug!("Could not close WebSocket: {:?}", e); + } + self.outgoing_keep_alive_set.clear(); + break; + } tracing::debug!("sending keep-alive"); let request = WebSocketRequestMessage::new(Method::GET) .id(self.next_request_id()) From e73644b7358ab9c2b4d10319df0f6eb253666607 Mon Sep 17 00:00:00 2001 From: Frauk Date: Tue, 19 Nov 2024 15:58:39 +0000 Subject: [PATCH 2/2] restart websocket at first missing keepalive --- src/websocket/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/websocket/mod.rs b/src/websocket/mod.rs index 888222f49..62bb6a807 100644 --- a/src/websocket/mod.rs +++ b/src/websocket/mod.rs @@ -201,7 +201,7 @@ impl SignalWebSocketProcess { futures::select! { _ = ka_interval.tick().fuse() => { use prost::Message; - if self.outgoing_keep_alive_set.len() > 6 { + if self.outgoing_keep_alive_set.len() > 0 { tracing::warn!("Websocket will be closed due to failed keepalives."); if let Err(e) = self.ws.close(reqwest_websocket::CloseCode::Away, None).await { tracing::debug!("Could not close WebSocket: {:?}", e);