diff --git a/src/http/ws.rs b/src/http/ws.rs index 41d70ab..9ee668a 100644 --- a/src/http/ws.rs +++ b/src/http/ws.rs @@ -38,8 +38,7 @@ async fn handle_connection(mut ws_stream: WebSocketStream, chats: Chat biased; msg = ws_stream.next() => { match msg { - Some(msg) => { - let msg = msg.unwrap(); + Some(Ok(msg)) => { let txt = msg.to_text().unwrap().to_string(); tracing::info!("Received a message: {txt}, sub_id={sub_id}"); match chats.broadcast(format!("{sub_id}: {txt}").as_str()).await { @@ -49,6 +48,10 @@ async fn handle_connection(mut ws_stream: WebSocketStream, chats: Chat }, } }, + Some(Err(err)) => { + tracing::warn!("Client {sub_id} failure: {err}"); + break; + } None => { tracing::info!("Client {sub_id} closed the socket, stopping.."); break;