Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Commit 0b1f0ca

Browse files
stop heartbeat timers on subscription removal
1 parent 01f99d0 commit 0b1f0ca

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

opcpublisher/OpcMonitoredItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public void MonitoredItemNotificationEventHandler(MonitoredItem monitoredItem, M
456456
else
457457
{
458458
Logger.Debug($"Enqueue a new message from subscription {(monitoredItem.Subscription == null ? "removed" : monitoredItem.Subscription.Id.ToString(CultureInfo.InvariantCulture))}");
459-
Logger.Debug($" with publishing interval: {monitoredItem.Subscription.PublishingInterval} and sampling interval: {monitoredItem.SamplingInterval}):");
459+
Logger.Debug($" with publishing interval: {monitoredItem?.Subscription?.PublishingInterval} and sampling interval: {monitoredItem?.SamplingInterval}):");
460460
}
461461

462462
// setupo heartbeat processing

opcpublisher/OpcSession.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ public async Task<bool> StopMonitoringNodesAsync(CancellationToken ct)
618618
{
619619
// nodes may be tagged for stop before they are monitored, just continue
620620
}
621+
// stop heartbeat timer for all items to remove
622+
foreach (var itemToRemove in itemsToRemove)
623+
{
624+
itemToRemove?.HeartbeatSendTimer?.Change(Timeout.Infinite, Timeout.Infinite);
625+
}
621626
// remove them in our data structure
622627
opcSubscription.OpcMonitoredItems.RemoveAll(i => i.State == OpcMonitoredItemState.RemovalRequested);
623628
Interlocked.Increment(ref NodeConfigVersion);

0 commit comments

Comments
 (0)