nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

commit 3b2516085245db73f17545cc4a38997f07ff7071
parent 34ad549cde8ebe0000f1f0386f1e7049c8180960
Author: Greg Heartsfield <scsibug@imap.cc>
Date:   Mon, 21 Feb 2022 08:46:01 -0600

fix: abort on connection IO errors

Diffstat:
Msrc/main.rs | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git 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::<String>(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; } };