mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 00:59:07 -05:00
fix: abort on connection IO errors
This commit is contained in:
parent
34ad549cde
commit
3b25160852
12
src/main.rs
12
src/main.rs
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user