From 2d80266422377e215cf27d6756b99bbcd55c5289 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 24 Mar 2026 12:50:55 +0800 Subject: [PATCH] fix(opcua): trigger reconnect on BadTimeout and tighten subscription params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the special-case that silently ignored BadTimeout in the subscription status callback. BadTimeout means the server has already dropped the subscription, so reconnect must be triggered immediately rather than waiting for the heartbeat check. Also reduce lifetime_count (120→15) and max_keep_alive_count (10→5) so failures are detected within 15s instead of 120s, while still satisfying the OPC UA spec requirement of lifetime >= 3×keepalive. Co-Authored-By: Claude Sonnet 4.6 --- src/connection.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index 6a3d7a5..9a980f8 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -1153,21 +1153,14 @@ impl ConnectionManager { match session .create_subscription( Duration::from_secs(1), - 120, - 10, + 15, + 5, 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,