Skip to content

Commit 1b85614

Browse files
committed
fix: renew IDLE timeout on keepalives and reduce it to 5 minutes
This change depends on async-imap update that resets the timeout every time an `* OK Still here` is received. Reducing timeout allows to detect lost connections not later than 6 minutes because Delta Chat will attempt to finish IDLE with DONE after 5 minutes without keepalives and will either get TCP RST directly or, worst case, wait another minute for TCP socket read timeout.
1 parent 57ecf49 commit 1b85614

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ratelimit = { path = "./deltachat-ratelimit" }
4040

4141
anyhow = "1"
4242
async-channel = "2.0.0"
43-
async-imap = { version = "0.9.1", default-features = false, features = ["runtime-tokio"] }
43+
async-imap = { version = "0.9.5", default-features = false, features = ["runtime-tokio"] }
4444
async-native-tls = { version = "0.5", default-features = false, features = ["runtime-tokio"] }
4545
async-smtp = { version = "0.9", default-features = false, features = ["runtime-tokio"] }
4646
async_zip = { version = "0.0.12", default-features = false, features = ["deflate", "fs"] }

src/imap/idle.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ use crate::context::Context;
1212
use crate::imap::{client::IMAP_TIMEOUT, FolderMeaning};
1313
use crate::log::LogExt;
1414

15-
const IDLE_TIMEOUT: Duration = Duration::from_secs(23 * 60);
15+
/// Timeout after which IDLE is finished
16+
/// if there are no responses from the server.
17+
///
18+
/// If `* OK Still here` keepalives are sent more frequently
19+
/// than this duration, timeout should never be triggered.
20+
/// For example, Dovecot sends keepalives every 2 minutes by default.
21+
const IDLE_TIMEOUT: Duration = Duration::from_secs(5 * 60);
1622

1723
impl Session {
1824
pub async fn idle(

0 commit comments

Comments
 (0)