-
Notifications
You must be signed in to change notification settings - Fork 1k
[Server] Refactor for full async subscription management #3442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Server] Refactor for full async subscription management #3442
Conversation
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.
There was a problem hiding this 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
ValueTaskorTaskreturn types with async/await - Methods return response objects instead of using
outparameters - 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; |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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.
| using System.Runtime.InteropServices; |
| } | ||
|
|
||
| if (m_shutdownEvent.WaitOne(timeToWait)) | ||
| if (m_shutdownEvent.WaitOne(0)) |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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.
| #if !NET9_0_OR_GREATER | ||
| #endif | ||
|
|
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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.
| #if !NET9_0_OR_GREATER | |
| #endif |
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.
Types of changes
Checklist
Further comments