From 3b2516085245db73f17545cc4a38997f07ff7071 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Mon, 21 Feb 2022 08:46:01 -0600 Subject: [PATCH] fix: abort on connection IO errors --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 98fd8d1..b871d29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -375,7 +375,7 @@ async fn nostr_server( // Create channel for receiving NOTICEs let (notice_tx, mut notice_rx) = mpsc::channel::(32); - // last time this client sent data + // last time this client sent data (message, ping, etc.) let mut last_message_time = Instant::now(); // ping interval (every 5 minutes) @@ -466,9 +466,15 @@ async fn nostr_server( debug!("normal websocket close from client: {:?}",cid); break; }, + Some(Err(WsError::Io(e))) => { + // IO errors are considered fatal + warn!("IO error (client: {:?}): {:?}", cid, e); + break; + } x => { - info!("message was: {:?} (ignoring)", x); - continue; + // default condition on error is to close the client connection + info!("unknown error (client: {:?}): {:?} (closing conn)", cid, x); + break; } };