[Server] Make SubscriptionManagement Methods Async & Fix Publishing of GoodSubscriptionTransferred Message#3350
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3350 +/- ##
==========================================
+ Coverage 51.86% 60.00% +8.14%
==========================================
Files 370 371 +1
Lines 78618 78217 -401
Branches 13650 13600 -50
==========================================
+ Hits 40779 46938 +6159
+ Misses 33705 26976 -6729
- Partials 4134 4303 +169 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the OPC UA .NET Standard Server subscription management by converting synchronous methods to async/await patterns and replacing Lock with SemaphoreSlim for better async compatibility. The changes enable proper async operation throughout the subscription lifecycle while fixing a bug that prevented publishing Good status codes for subscription transfer notifications.
Key Changes:
- Replaced
LockwithSemaphoreSliminSubscriptionManagerfor async-compatible synchronization - Converted subscription lifecycle methods (
StartupAsync,ShutdownAsync,RestoreSubscriptionsAsync, etc.) to async - Removed synchronous wrapper methods from
MasterNodeManagerthat used blocking calls on async methods - Fixed
SessionPublishQueue.TryPublishCustomStatusto properly handle Good status codes by returning null subscription instead of throwing an exception
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Stack/Opc.Ua.Core/Opc.Ua.Core.csproj | Removed OPCUA_EXCLUDE flags to enable async methods for subscription-related operations |
| Tests/Opc.Ua.Server.Tests/ServerTestServices.cs | Updated test service methods to call async server methods directly instead of using sync wrappers |
| Libraries/Opc.Ua.Server/Subscription/SubscriptionManager.cs | Replaced Lock with SemaphoreSlim; converted lifecycle methods to async; updated synchronization patterns |
| Libraries/Opc.Ua.Server/Subscription/Subscription.cs | Added RestoreAsync factory method; converted ConditionRefresh and SetMonitoringMode methods to async |
| Libraries/Opc.Ua.Server/Subscription/SessionPublishQueue.cs | Fixed TryPublishCustomStatus to handle Good status codes by returning null instead of throwing |
| Libraries/Opc.Ua.Server/Subscription/ISubscriptionManager.cs | Updated interface signatures to async methods |
| Libraries/Opc.Ua.Server/Subscription/ISubscription.cs | Updated interface signatures to async methods |
| Libraries/Opc.Ua.Server/Server/StandardServer.cs | Converted subscription and node management methods to async; updated to return response objects directly |
| Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs | Removed sync wrapper methods; added cancellation token parameter to ShutdownAsync |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Proposed changes
Related Issues
Types of changes
Checklist