From 04e415eb0cd2f86f24e189223c055f30610b6265 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 3 Feb 2020 11:48:26 +0000 Subject: [PATCH] No more panics on websocket handshake error --- nym-client/src/sockets/ws.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nym-client/src/sockets/ws.rs b/nym-client/src/sockets/ws.rs index c97cb87883..73d8df3898 100644 --- a/nym-client/src/sockets/ws.rs +++ b/nym-client/src/sockets/ws.rs @@ -318,9 +318,13 @@ async fn accept_connection( .expect("connected streams should have a peer address"); debug!("Peer address: {}", address); - let mut ws_stream = tokio_tungstenite::accept_async(stream) - .await - .expect("Error during the websocket handshake occurred"); + let mut ws_stream = match tokio_tungstenite::accept_async(stream).await { + Ok(ws_stream) => ws_stream, + Err(e) => { + error!("Error during the websocket handshake occurred - {}", e); + return; + } + }; // Create a channel for our stream, which other sockets will use to // send us messages. Then register our address with the stream to send