Skip to content

Commit

Permalink
Merge pull request #347 from fraukappayuwe/patch-1
Browse files Browse the repository at this point in the history
Close websocket when keepalive are no longer received
  • Loading branch information
rubdos authored Nov 20, 2024
2 parents 268e0c4 + e73644b commit e6affcc
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() > 0 {

Check warning on line 204 in src/websocket/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

length comparison to zero

warning: length comparison to zero --> src/websocket/mod.rs:204:24 | 204 | if self.outgoing_keep_alive_set.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!self.outgoing_keep_alive_set.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `#[warn(clippy::len_zero)]` on by default
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 e6affcc

Please sign in to comment.