fix: abort on connection IO errors

This commit is contained in:
Greg Heartsfield 2022-02-21 08:46:01 -06:00
parent 34ad549cde
commit 3b25160852

View File

@ -375,7 +375,7 @@ async fn nostr_server(
// Create channel for receiving NOTICEs // Create channel for receiving NOTICEs
let (notice_tx, mut notice_rx) = mpsc::channel::<String>(32); let (notice_tx, mut notice_rx) = mpsc::channel::<String>(32);
// last time this client sent data // last time this client sent data (message, ping, etc.)
let mut last_message_time = Instant::now(); let mut last_message_time = Instant::now();
// ping interval (every 5 minutes) // ping interval (every 5 minutes)
@ -466,9 +466,15 @@ async fn nostr_server(
debug!("normal websocket close from client: {:?}",cid); debug!("normal websocket close from client: {:?}",cid);
break; break;
}, },
Some(Err(WsError::Io(e))) => {
// IO errors are considered fatal
warn!("IO error (client: {:?}): {:?}", cid, e);
break;
}
x => { x => {
info!("message was: {:?} (ignoring)", x); // default condition on error is to close the client connection
continue; info!("unknown error (client: {:?}): {:?} (closing conn)", cid, x);
break;
} }
}; };