From 0b9b7aef7dd67cbef2b3736cde04169e95566569 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 24 Mar 2026 12:28:23 +0800 Subject: [PATCH] fix(opcua): relax subscription timeout handling --- src/connection.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index 5463bd5..6a3d7a5 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -328,7 +328,7 @@ impl ConnectionManager { let manager = self.clone(); let handle = tokio::spawn(async move { - let mut ticker = tokio::time::interval(Duration::from_secs(4)); // 每4秒检测一次心跳 + let mut ticker = tokio::time::interval(Duration::from_secs(8)); // 每8秒检测一次心跳 ticker.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip); loop { @@ -1153,14 +1153,21 @@ impl ConnectionManager { match session .create_subscription( Duration::from_secs(1), + 120, 10, - 30, 0, 0, true, opcua::client::SubscriptionCallbacks::new( move |notification| { if notification.status.is_bad() { + if notification.status == opcua::types::StatusCode::BadTimeout { + tracing::warn!( + "Subscription publish timeout for source {}, waiting for heartbeat validation before reconnect", + current_source_id + ); + return; + } tracing::warn!( "Subscription status changed to {:?} for source {}, triggering reconnection", notification.status,