Skip to content

Conversation

@romanett
Copy link
Contributor

@romanett romanett commented Jan 7, 2026

Proposed changes

Refactor server for full async subscription management

Refactor to make OPC UA server subscription and monitored item management fully asynchronous, improving scalability and responsiveness. All key methods in ISubscription, ISubscriptionManager, and related classes are now async, with synchronous counterparts removed.

  • move CustomNodeManager & CustomNodeManagerAsync -> NodeManager folder
  • move SystemConfigurationIdentity to separate file
  • check loglevel before executing LogCall that shows in Profiling
  • remove unecessary lock in ReferenceNodeManager
  • allow to Run Load Test with SamplingGroups

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

Refactor to make OPC UA server subscription and monitored item management fully asynchronous, improving scalability and responsiveness. All key methods in ISubscription, ISubscriptionManager, and related classes are now async, with synchronous counterparts removed.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the OPC UA server to use fully asynchronous subscription and monitored item management, replacing synchronous methods with async/await patterns. This improves scalability and responsiveness by eliminating blocking operations throughout the subscription lifecycle.

Key changes:

  • All subscription and monitored item operations now use ValueTask or Task return types with async/await
  • Methods return response objects instead of using out parameters
  • Removed synchronous wrappers that blocked on async operations

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Tests/Opc.Ua.Client.Tests/LoadTest.cs Adds configuration flag to disable sampling groups in test framework
Tests/Opc.Ua.Client.Tests/ClientTestFramework.cs Introduces property to control sampling group usage in reference server
Libraries/Opc.Ua.Server/Subscription/SubscriptionManager.cs Converts all subscription management methods to async, changes return types to response objects
Libraries/Opc.Ua.Server/Subscription/Subscription.cs Makes monitored item operations async and returns response objects instead of out parameters
Libraries/Opc.Ua.Server/Subscription/MonitoredItem/MonitoredItem.cs Adds log level check before expensive trace logging operations
Libraries/Opc.Ua.Server/Subscription/ISubscriptionManager.cs Updates interface to declare async methods with response object returns
Libraries/Opc.Ua.Server/Subscription/ISubscription.cs Changes interface to use async methods with ValueTask returns
Libraries/Opc.Ua.Server/Server/StandardServer.cs Updates endpoint implementations to await async operations; fixes indentation
Libraries/Opc.Ua.Server/Server/ServerInternalData.cs Makes session closing and subscription deletion async
Libraries/Opc.Ua.Server/Server/IServerInternal.cs Updates interface to declare DeleteSubscriptionAsync
Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs Removes synchronous wrapper methods, marks obsolete methods
Libraries/Opc.Ua.Server/Configuration/SystemConfigurationIdentity.cs Extracts SystemConfigurationIdentity class to separate file
Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs Removes SystemConfigurationIdentity class (now in separate file)
Applications/Quickstarts.Servers/ReferenceServer/ReferenceNodeManager.cs Removes unnecessary lock in GetManagerHandle

using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The System.Runtime.InteropServices namespace is imported but does not appear to be used in this file. Consider removing this unused import.

Suggested change
using System.Runtime.InteropServices;

Copilot uses AI. Check for mistakes.
}

if (m_shutdownEvent.WaitOne(timeToWait))
if (m_shutdownEvent.WaitOne(0))
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wait time has been hardcoded to 0 instead of using the calculated timeToWait. This changes the behavior from waiting for the shutdown event with a timeout to polling it immediately. This could increase CPU usage as the loop will spin without delay when no subscriptions need processing. The delay now happens unconditionally via Task.Delay on line 2155, but if shutdown is signaled, the loop will unnecessarily delay before checking again.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +32
#if !NET9_0_OR_GREATER
#endif

Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These preprocessor directives are empty and serve no purpose. Consider removing them or adding the intended conditional compilation code.

Suggested change
#if !NET9_0_OR_GREATER
#endif

Copilot uses AI. Check for mistakes.
@marcschier marcschier merged commit a3a6709 into master Jan 8, 2026
118 checks passed
@romanett romanett deleted the romanett/Server_Async_SubscriptionManagement branch January 8, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants