mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-13 22:49:07 -05:00
feat: add network.ping_interval setting
Add a ping interval setting that allows you to customize the websocket ping interval. The default of 5 minutes may be too high for some proxy servers that disconnect connections that are held open for too long.
This commit is contained in:
parent
a6cb6f8486
commit
50577b2dfa
|
@ -51,6 +51,9 @@ port = 8080
|
|||
#remote_ip_header = "x-forwarded-for"
|
||||
#remote_ip_header = "cf-connecting-ip"
|
||||
|
||||
# Websocket ping interval in seconds, defaults to 5 minutes
|
||||
#ping_interval = 300
|
||||
|
||||
[options]
|
||||
# Reject events that have timestamps greater than this many seconds in
|
||||
# the future. Recommended to reject anything greater than 30 minutes
|
||||
|
|
|
@ -29,6 +29,7 @@ pub struct Network {
|
|||
pub port: u16,
|
||||
pub address: String,
|
||||
pub remote_ip_header: Option<String>, // retrieve client IP from this HTTP header if present
|
||||
pub ping_interval: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -207,6 +208,7 @@ impl Default for Settings {
|
|||
},
|
||||
network: Network {
|
||||
port: 8080,
|
||||
ping_interval: 300,
|
||||
address: "0.0.0.0".to_owned(),
|
||||
remote_ip_header: None,
|
||||
},
|
||||
|
|
|
@ -427,7 +427,7 @@ async fn nostr_server(
|
|||
let mut last_message_time = Instant::now();
|
||||
|
||||
// ping interval (every 5 minutes)
|
||||
let default_ping_dur = Duration::from_secs(300);
|
||||
let default_ping_dur = Duration::from_secs(settings.network.ping_interval.into());
|
||||
|
||||
// disconnect after 20 minutes without a ping response or event.
|
||||
let max_quiet_time = Duration::from_secs(60 * 20);
|
||||
|
|
Loading…
Reference in New Issue
Block a user