Skip to content

Commit

Permalink
Fixed websocket closing by client
Browse files Browse the repository at this point in the history
  • Loading branch information
myOmikron committed Apr 29, 2023
1 parent aa57b5e commit e222a5c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/server/handler/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ pub async fn websocket(
if Instant::now().duration_since(*hb_time.lock().await) > CLIENT_TIMEOUT
&& hb_tx.close().await.is_ok()
{
if let Err(err) = hb_ws_manager
.send(WsManagerMessage::WebsocketClosed(hb_uuid))
.await
{
warn!("Could not send to ws_manager_chan: {err}");
}
debug!("Closed websocket due to missing heartbeat responses");
}

Expand Down Expand Up @@ -105,13 +99,7 @@ pub async fn websocket(
Message::Ping(req) => {
if let Err(err) = rx_tx.send(Message::Ping(req)).await {
if let MailboxError::Closed = err {
debug!("Websocket closed");
if let Err(err) = rx_ws_manager
.send(WsManagerMessage::WebsocketClosed(rx_uuid))
.await
{
warn!("Could not send to ws_manager_chan: {err}");
}
debug!("Could not ping send to ws: websocket closed");
break;
}
debug!("Sending to ran into tx timeout");
Expand All @@ -121,6 +109,10 @@ pub async fn websocket(
let mut r = last_hb.lock().await;
*r = Instant::now();
}
Message::Close(_) => {
debug!("Client closed websocket");
break;
}
_ => {
invalid_msg!(rx_tx);
debug!("Received invalid message type via websocket");
Expand Down

0 comments on commit e222a5c

Please sign in to comment.