Treat zero MaxNotificationsPerPublish as unlimited (OPC 10000-4) - #4047
Conversation
Preserve client limits when the server has no configured cap and drain notification queues when the effective limit is zero. Implements OPC 10000-4 Sections 5.13.2.2 and 5.13.3.2. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Implements OPC UA “zero means unlimited” semantics for MaxNotificationsPerPublish, ensuring publish message construction drains notification queues when the effective limit is 0, and revising client-requested limits correctly against the server maximum.
Changes:
- Update subscription publish message construction to treat an effective 0 notification limit as unlimited.
- Fix max-notifications revision logic in
SubscriptionManagerto preserve non-zero client requests when the server max is 0/unlimited. - Add regression tests for queue draining with a zero limit and for client/server limit revision behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/Opc.Ua.Server/Subscription/Subscription.cs | Treats server-side effective 0 as unlimited during message construction so queues drain. |
| src/Opc.Ua.Server/Subscription/SubscriptionManager.cs | Revises requested MaxNotificationsPerPublish using OPC UA zero/unlimited rules. |
| tests/Opc.Ua.Server.Tests/SubscriptionTests.cs | Adds targeted regression tests for zero/unlimited semantics and revision logic. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4047 +/- ##
==========================================
+ Coverage 73.55% 73.74% +0.18%
==========================================
Files 1345 1352 +7
Lines 180036 182979 +2943
Branches 31677 32148 +471
==========================================
+ Hits 132427 134929 +2502
- Misses 36911 37253 +342
- Partials 10698 10797 +99
🚀 New features to boost your workflow:
|
## Proposed changes Backport commit a5dd6ea (#4047) to `master378`. OPC UA defines zero as no notification limit. The message builder compared the queued count directly with zero, so an effective zero limit emitted no event or data-change notifications and left the queues pending. Separately, the revision logic treated a configured Server maximum of zero as a numeric cap, revising a non-zero Client request to zero and silently removing the Client's requested limit. ### Fix - Treat an effective zero limit as unlimited while draining event and data-change queues. - When the Client requests zero, use the Server's configured maximum, which may itself remain zero/unlimited. - When the Server maximum is zero, preserve a non-zero Client request, including `uint.MaxValue`. - When the Server maximum is finite, cap zero, `uint.MaxValue`, and larger finite Client requests to that maximum. - Cover the same revision matrix through both CreateSubscription and ModifySubscription. ## Related Issues - Backport of #4047 (commit `a5dd6eae7cc1ab074d62d723194285952560555f`) ## Types of changes - [x] Bugfix (non-breaking change which fixes an issue) - [ ] Enhancement (non-breaking change which adds functionality) - [x] 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 - [x] I have read the [CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md) doc. - [x] I have signed the [CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf). - [x] 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. - [x] I have added tests that prove my fix is effective or that my feature works and increased code coverage. - [x] I have added necessary documentation (if appropriate). - [ ] Any dependent changes have been merged and published in downstream modules. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description
This focused change extracts the
MaxNotificationsPerPublishconformance fix from #4021. It contains onlySubscription.cs,SubscriptionManager.cs, and focusedSubscriptionTests.Failure
OPC UA defines zero as no notification limit. The message builder compared the queued count directly with zero, so an effective zero limit emitted no event or data-change notifications and left the queues pending. Separately, the revision logic treated a configured Server maximum of zero as a numeric cap, revising a non-zero Client request to zero and silently removing the Client's requested limit.
Fix
uint.MaxValue.uint.MaxValue, and larger finite Client requests to that maximum.This implements the zero-means-unlimited semantics in OPC 10000-4 v1.05.07 Sections 5.14.2.2 and 5.14.3.2. Those Service responses do not contain a
revisedMaxNotificationsPerPublishfield; the effective value is retained by the Server-side Subscription and its diagnostics.Tests
dotnet test tests\Opc.Ua.Server.Tests\Opc.Ua.Server.Tests.csproj -f net10.0 --filter "FullyQualifiedName~Opc.Ua.Server.Tests.SubscriptionTests" --no-restore: 25 passed.dotnet test tests\Opc.Ua.Server.Tests\Opc.Ua.Server.Tests.csproj -f net48 --filter "FullyQualifiedName~Opc.Ua.Server.Tests.SubscriptionTests" --no-restore: 25 passed.The regression tests cover zero, finite, and
uint.MaxValueClient requests against unlimited and finite Server limits for both CreateSubscription and ModifySubscription. They also verify that zero drains both event and data-change queues.Related Issues
Checklist