Skip to content

Commit

Permalink
close websocket when keepalive are no longer received
Browse files Browse the repository at this point in the history
  • Loading branch information
fraukappayuwe authored Nov 19, 2024
1 parent c6b6eac commit 9502d4c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/websocket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 9502d4c

Please sign in to comment.