From 2cb8749adeb0ade0e620188a9ea6d70c9edfd7fd Mon Sep 17 00:00:00 2001 From: Charles Schleich Date: Tue, 26 Nov 2024 17:24:04 +0100 Subject: [PATCH] Fix panic if WS handshake fails at runtime (#51) --- zenoh-plugin-remote-api/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/zenoh-plugin-remote-api/src/lib.rs b/zenoh-plugin-remote-api/src/lib.rs index c57a3db..f1e5fe3 100644 --- a/zenoh-plugin-remote-api/src/lib.rs +++ b/zenoh-plugin-remote-api/src/lib.rs @@ -608,9 +608,13 @@ async fn run_websocket_server( None => Box::new(tcp_stream), }; - let ws_stream = tokio_tungstenite::accept_async(streamable) - .await - .expect("Error during the websocket handshake occurred"); + let ws_stream = match tokio_tungstenite::accept_async(streamable).await { + Ok(ws_stream) => ws_stream, + Err(e) => { + error!("Error during the websocket handshake occurred: {}", e); + return; + } + }; let (ws_tx, ws_rx) = ws_stream.split();