From 664d7e5a15f9928518cee5e7cfe80fbeb48d0a53 Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Fri, 21 Aug 2026 11:49:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(channels):=20=E9=A3=9E=E4=B9=A6=E9=A2=91?= =?UTF-8?q?=E9=81=93=E6=96=AD=E7=BA=BF=E9=87=8D=E8=BF=9E=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=8C=87=E6=95=B0=E9=80=80=E9=81=BF=E6=97=A0=E9=99=90=E9=87=8D?= =?UTF-8?q?=E8=AF=95=EF=BC=8C=E7=BD=91=E7=BB=9C=E6=81=A2=E5=A4=8D=E5=90=8E?= =?UTF-8?q?=E8=87=AA=E6=84=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/channels/feishu.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/channels/feishu.rs b/src/channels/feishu.rs index 0b856a4..09b56bc 100644 --- a/src/channels/feishu.rs +++ b/src/channels/feishu.rs @@ -2308,8 +2308,9 @@ impl Channel for FeishuChannel { let channel = self.clone(); let bus = bus.clone(); tokio::spawn(async move { - let mut consecutive_failures = 0; - let max_failures = 3; + let mut consecutive_failures: u32 = 0; + let base_retry_secs: u64 = 5; + let max_retry_secs: u64 = 60; loop { if !*channel.running.read().await { @@ -2319,15 +2320,12 @@ impl Channel for FeishuChannel { let shutdown_rx = shutdown_tx.subscribe(); match channel.run_ws_loop(bus.clone(), shutdown_rx).await { Ok(_) => { + consecutive_failures = 0; tracing::info!("Feishu WebSocket disconnected"); } Err(e) => { - consecutive_failures += 1; + consecutive_failures = consecutive_failures.saturating_add(1); tracing::error!(attempt = consecutive_failures, error = %e, "Feishu WebSocket error"); - if consecutive_failures >= max_failures { - tracing::error!("Feishu channel: max failures reached, stopping"); - break; - } } } @@ -2335,8 +2333,15 @@ impl Channel for FeishuChannel { break; } - tracing::info!("Feishu channel retrying in 5s..."); - tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; + let exponent = consecutive_failures.saturating_sub(1).min(6); + let retry_secs = (base_retry_secs * (1u64 << exponent)).min(max_retry_secs); + tracing::info!("Feishu channel retrying in {}s...", retry_secs); + let mut remaining = retry_secs; + while remaining > 0 && *channel.running.read().await { + let step = remaining.min(base_retry_secs); + tokio::time::sleep(tokio::time::Duration::from_secs(step)).await; + remaining -= step; + } } *channel.running.write().await = false;