Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 10, 2025

Issue

When a client disconnects from the server with outstanding publish requests, the server logs warning messages like:

[16:12:20 WRN] SERVER - Service Fault Occurred. Reason=BadNoSubscription

This is not an exceptional case and should not generate warning logs. In production environments, these warnings accumulate and spam log files, making it difficult to identify real issues that require attention.

Root Cause

When SubscriptionManager.DeleteSubscription is called during client disconnection, outstanding publish requests in SessionPublishQueue are completed with BadNoSubscription status code. The SessionPublishQueue.Publish method then throws a ServiceResultException, which is caught by EndpointBase.CreateFault. This method was logging all ServiceResultException instances at Warning level, regardless of whether they represent expected scenarios.

Solution

Modified EndpointBase.CreateFault to log at Information level instead of Warning level for status codes that represent expected client disconnection and operational scenarios:

  • BadNoSubscription - Client disconnects with outstanding publish requests
  • BadSessionClosed - Session closed normally
  • BadSecurityChecksFailed - Security validation failed
  • BadCertificateInvalid - Certificate validation failed
  • BadServerHalted - Server shutting down

All other service faults continue to log at Warning level, preserving the ability to detect unexpected issues.

Rationale

These status codes are already handled as expected scenarios in the client code (Session.OnPublishComplete, lines 5786-5791) where they simply return without logging errors. The server-side logging should align with this behavior.

Testing

  • ✅ All Core tests passed (24,625/24,625)
  • ✅ All Server tests passed (134/134)
  • ✅ Solution builds successfully

Impact

  • Reduces noise in server logs
  • Improves log quality by only showing warnings for actual issues
  • Makes it easier to identify real problems that require attention
  • Aligns server logging behavior with client expectations

Fixes issue where normal client disconnection scenarios generate excessive warning logs.

Co-authored-by: romanett 7413710+romanett@users.noreply.github.com

Original prompt

This section details on the original issue you should resolve

<issue_title>Client disconnect from server with outstanding publish request causes log messages with level=Warning</issue_title>
<issue_description>### Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

When a client disconnects from the server in a regular manner the stack throws ServiceResultException(request.Error) in the SessionPublishQueue class. This causes the logger to output a log message with warning level:

[16:12:20 WRN] SERVER - Service Fault Occurred. Reason=BadNoSubscription

Observed behavior

In the SessionPublishQueue for the subscription of the client managed by the SubscriptionManager there are two QueuedRequest instances which are processed by the SessionPublishQueue.Publish method but blocking the execution with line 491 in SessionPublishQueue.cs. When the SubscriptionManager.DeleteSubscription (line 885) method is called - the call to SessionPublishQueue.Remove causes the QueuedRequest.Event to be set, with the Error field of the QueuedRequest set to BadNoSubscription status code. The call to Set()of the QueuedRequest.Event field causes the execution of the SessionPublishQueue.Publish method to continue, but run into the branch where the ServiceResultException is thrown.

Question / Issue

This scenario should not cause a warning log message, since this is a non exceptional use case. In our scenario those log messages add up and spam / fill the log file of the application running the server.
Is there a way to create a server with a proper configuration which does not cause this log message?

Expected Behavior

I would expect to have the option to remove a subscription / disconnect a client without causing a ServiceFault warning.

Steps To Reproduce

  1. Start the ConsoleReferenceServer project
  2. Connect with a client, for example UaExpert
  3. Disconnect the client
  4. Log messages will appear in the output either debug or console

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version:
- Component:
- Server:
- Client:

Anything else?

No response</issue_description>

<agent_instructions>Please update the Server Library to log an Information instead of an Error in this case </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@romanett @larws I agree with you on both issues.

This case should not log a warning, as it is caused by the client and no server issue.

Regarding the client, it should wait for outstanding publish requests on close, or cancel the outstanding requests (I need to look up if the server supports cancelling publish requests).

Fixes #3215


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

…on status codes

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix client disconnect log messages with warning level Fix log level for expected client disconnection scenarios (BadNoSubscription and related status codes) Oct 10, 2025
Copilot AI requested a review from romanett October 10, 2025 15:45
@romanett romanett marked this pull request as ready for review October 11, 2025 09:32
@codecov
Copy link

codecov bot commented Oct 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.76%. Comparing base (01ffcee) to head (665d1f8).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3255      +/-   ##
==========================================
- Coverage   57.77%   57.76%   -0.01%     
==========================================
  Files         362      362              
  Lines       79251    79257       +6     
  Branches    13840    13841       +1     
==========================================
- Hits        45786    45784       -2     
- Misses      29242    29245       +3     
- Partials     4223     4228       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcschier marcschier merged commit 7560307 into master Oct 12, 2025
119 of 146 checks passed
@marcschier marcschier deleted the copilot/fix-client-disconnect-logging branch October 12, 2025 05:59
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.

Client disconnect from server with outstanding publish request causes log messages with level=Warning

4 participants