-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix client Close method to properly terminate outstanding publish requests #3254
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
base: master
Are you sure you want to change the base?
Conversation
|
…ic in CloseAsync Co-authored-by: romanett <[email protected]>
Co-authored-by: romanett <[email protected]>
Co-authored-by: romanett <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3254 +/- ##
==========================================
+ Coverage 57.74% 57.76% +0.02%
==========================================
Files 365 365
Lines 79419 79495 +76
Branches 13865 13880 +15
==========================================
+ Hits 45862 45922 +60
- Misses 29310 29323 +13
- Partials 4247 4250 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e.AcknowledgementsToSend.Clear(); | ||
} | ||
|
||
/// <summary> |
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 tests are really bad, either improve or remove
Problem
The OPC UA client's
Close
method does not properly terminate outstanding publish requests before closing the session, which violates the OPC UA standard and can lead to ServiceFault responses from the server.According to OPC UA Part 4, Section 5.6.4: "Clients are urged to wait for all outstanding requests to complete before submitting the CloseSession request."
Current Behavior
When closing a session with active subscriptions:
Expected Behavior
Before closing a session, the client should:
Solution
This PR adds proper handling of outstanding publish requests during session close:
1. New Configuration Property
Added
PublishRequestCancelWaitTimeout
property to control the wait behavior:2. Enhanced Close Flow
The
CloseAsync
method now:3. Implementation Details
WaitForOrCancelOutstandingPublishRequestsAsync()
handles the wait/cancel logicCancellationToken
for early terminationTesting
Breaking Changes
None. This change is backward compatible with a sensible default timeout of 5 seconds.
Benefits
✅ Standards Compliant: Follows OPC UA Part 4 recommendations
✅ Reduces ServiceFaults: Prevents errors from orphaned publish requests
✅ Configurable: Applications can choose the appropriate wait strategy
✅ Backward Compatible: Default behavior is a reasonable compromise
✅ Reliable: Improves client stability during shutdown
Fixes #1821
Original prompt
Fixes #1778
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.