fix(opcua): relax subscription timeout handling

This commit is contained in:
caoqianming 2026-03-24 12:28:23 +08:00
parent c50127b9d0
commit 0b9b7aef7d
1 changed files with 9 additions and 2 deletions

View File

@ -328,7 +328,7 @@ impl ConnectionManager {
let manager = self.clone(); let manager = self.clone();
let handle = tokio::spawn(async move { 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); ticker.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
loop { loop {
@ -1153,14 +1153,21 @@ impl ConnectionManager {
match session match session
.create_subscription( .create_subscription(
Duration::from_secs(1), Duration::from_secs(1),
120,
10, 10,
30,
0, 0,
0, 0,
true, true,
opcua::client::SubscriptionCallbacks::new( opcua::client::SubscriptionCallbacks::new(
move |notification| { move |notification| {
if notification.status.is_bad() { 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!( tracing::warn!(
"Subscription status changed to {:?} for source {}, triggering reconnection", "Subscription status changed to {:?} for source {}, triggering reconnection",
notification.status, notification.status,