Skip to content

Commit 042f105

Browse files
committed
fix: default session keep_alive to 5 minutes
1 parent 52c93e9 commit 042f105

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • crates/rmcp/src/transport/streamable_http_server/session

crates/rmcp/src/transport/streamable_http_server/session/local.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,19 +1069,30 @@ impl Worker for LocalSessionWorker {
10691069
pub struct SessionConfig {
10701070
/// the capacity of the channel for the session. Default is 16.
10711071
pub channel_capacity: usize,
1072-
/// if set, the session will be closed after this duration of inactivity.
1072+
/// The session will be closed after this duration of inactivity.
1073+
///
1074+
/// This serves as a safety net for cleaning up sessions whose HTTP
1075+
/// connections have silently dropped (e.g., due to an HTTP/2
1076+
/// `RST_STREAM`). Without a timeout, such sessions become zombies:
1077+
/// the session worker keeps running indefinitely because the session
1078+
/// handle's sender is still held in the session manager, preventing
1079+
/// the worker's event channel from closing.
1080+
///
1081+
/// Defaults to 5 minutes. Set to `None` to disable (not recommended
1082+
/// for long-running servers behind proxies).
10731083
pub keep_alive: Option<Duration>,
10741084
}
10751085

10761086
impl SessionConfig {
10771087
pub const DEFAULT_CHANNEL_CAPACITY: usize = 16;
1088+
pub const DEFAULT_KEEP_ALIVE: Duration = Duration::from_secs(300);
10781089
}
10791090

10801091
impl Default for SessionConfig {
10811092
fn default() -> Self {
10821093
Self {
10831094
channel_capacity: Self::DEFAULT_CHANNEL_CAPACITY,
1084-
keep_alive: None,
1095+
keep_alive: Some(Self::DEFAULT_KEEP_ALIVE),
10851096
}
10861097
}
10871098
}

0 commit comments

Comments
 (0)