mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 00:59: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 = "x-forwarded-for"
|
||||||
#remote_ip_header = "cf-connecting-ip"
|
#remote_ip_header = "cf-connecting-ip"
|
||||||
|
|
||||||
|
# Websocket ping interval in seconds, defaults to 5 minutes
|
||||||
|
#ping_interval = 300
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
# Reject events that have timestamps greater than this many seconds in
|
# Reject events that have timestamps greater than this many seconds in
|
||||||
# the future. Recommended to reject anything greater than 30 minutes
|
# the future. Recommended to reject anything greater than 30 minutes
|
||||||
|
|
|
@ -29,6 +29,7 @@ pub struct Network {
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub address: String,
|
pub address: String,
|
||||||
pub remote_ip_header: Option<String>, // retrieve client IP from this HTTP header if present
|
pub remote_ip_header: Option<String>, // retrieve client IP from this HTTP header if present
|
||||||
|
pub ping_interval: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -207,6 +208,7 @@ impl Default for Settings {
|
||||||
},
|
},
|
||||||
network: Network {
|
network: Network {
|
||||||
port: 8080,
|
port: 8080,
|
||||||
|
ping_interval: 300,
|
||||||
address: "0.0.0.0".to_owned(),
|
address: "0.0.0.0".to_owned(),
|
||||||
remote_ip_header: None,
|
remote_ip_header: None,
|
||||||
},
|
},
|
||||||
|
|
|
@ -427,7 +427,7 @@ async fn nostr_server(
|
||||||
let mut last_message_time = Instant::now();
|
let mut last_message_time = Instant::now();
|
||||||
|
|
||||||
// ping interval (every 5 minutes)
|
// 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.
|
// disconnect after 20 minutes without a ping response or event.
|
||||||
let max_quiet_time = Duration::from_secs(60 * 20);
|
let max_quiet_time = Duration::from_secs(60 * 20);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user