Console App Behavior & UI Issues In OPC UA .NET Standard

by Admin 57 views
ConsoleReferenceServer and ConsoleRefereceClient Changed Default Behavior and UIDiscussion Category: OPCFoundation, UA-.NETStandard

Hey everyone! Let's dive into some changes in the default behavior and UI experience of the ConsoleReferenceServer and ConsoleReferenceClient within the OPCFoundation's UA-.NETStandard framework. This article aims to break down the issues, explain the expected behavior, and provide some context around these changes. So, grab your favorite beverage, and let's get started!

Type of Issue

  • [x] Bug
  • [ ] Enhancement
  • [ ] Compliance
  • [ ] Question
  • [ ] Help wanted

Current Behavior

The ConsoleReferenceServer and ConsoleReferenceClient have shown some changes in their default behavior and UI experience. Let's break down the two main issues:

Issue 1: Debug Mode Parameter Requirements

Debug mode now requires the --console and --log input parameters; otherwise, they throw errors. Let's illustrate with an example from ConsoleReferenceServer:

.NET Core OPC UA Reference Server
OPC UA library: 1.5.378.3 @ 11/13/2025 08:39:50 -- 1.5.378.3-preview+d25caffb03
Process terminated. Assertion failed.
Using a NullLogger
   at Opc.Ua.LoggerUtils.Null.DebugCheck() in C:\_Work\GIT\_TempClone\UA-.NETStandard\Stack\Opc.Ua.Types\Diagnostics\TelemetryUtils.cs:line 144
   at Opc.Ua.LoggerUtils.Null.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) in C:\_Work\GIT\_TempClone\UA-.NETStandard\Stack\Opc.Ua.Types\Diagnostics\TelemetryUtils.cs:line 124
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, String message, Object[] args)
   at Microsoft.Extensions.Logging.LoggerExtensions.LogInformation(ILogger logger, String message, Object[] args)
   at Quickstarts.ReferenceServer.Program.Main(String[] args) in C:\_Work\GIT\_TempClone\UA-.NETStandard\Applications\ConsoleReferenceServer\Program.cs:line 119
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Quickstarts.ReferenceServer.Program.Main(String[] args)
   at Quickstarts.ReferenceServer.Program.<Main>(String[] args) 

However, in Release mode, these input parameters aren't necessary. The downside? No useful messages are displayed on the console, as they're piped through the log mechanism, which leads us to Issue 2. For users who just want to run the console applications, enabling log messages shouldn't be a requirement. They should be able to depend on the application console to show relevant information, just like in previous versions.

Issue 2: Changed Console Output

Previously, the console output clearly and concisely displayed that the server had started and showed the discovery endpoints. For example:

.NET Core OPC UA Reference Server
OPC UA library: 1.5.377.22 @ 11/14/2025 14:29:09 -- 1.5.377.22+c09d97c3af
Loading configuration from Quickstarts.ReferenceServer.
Check the certificate.
Start the server.
opc.tcp://c-w-sum2:62541/Quickstarts/ReferenceServer
opc.https://c-w-sum2:62540/Quickstarts/ReferenceServer/
Server started. Press Ctrl-C to exit...

Now, the current version mixes console-only messages with other log messages, displaying them with an [INF] level:

[17:12:44 INF] Start the server.
[17:12:44 INF] The server is starting.
[17:12:44 INF] Server - Start application Quickstart Reference Server.
[17:12:44 INF] Server - CreateResourceManager.
[17:12:44 INF] Server - CreateRequestManager.
[17:12:44 INF] Server - CreateMasterNodeManager.
[17:12:44 INF] Creating the Reference Server Node Manager.
[17:12:44 INF] Alarms: Created AlarmNodeManager
[17:12:44 INF] MasterNodeManager.Startup - NodeManagers=7
[17:12:45 INF] Alarms: Starting simulation
[17:12:45 INF] Server - CreateEventManager.
[17:12:45 INF] Server - CreateAggregateManager.
[17:12:45 INF] Server - CreateModellingRulesManager.
[17:12:45 INF] Server - CreateSessionManager.
[17:12:45 INF] Server - Session Monitor Thread Started.
[17:12:45 INF] Server - CreateSubscriptionManager.
[17:12:45 INF] Subscription - ConditionRefresh Task 00000001 Started.
[17:12:45 INF] Subscription - Publish Task 00000002 Started.
[17:12:45 INF] Server - Enter Running state.
[17:12:45 INF] Server - Started.
[17:12:45 INF] Server - Configuration watcher started.
[17:12:45 INF] opc.tcp://c-w-sum2:62541/Quickstarts/ReferenceServer
[17:12:45 INF] opc.https://c-w-sum2:62540/Quickstarts/ReferenceServer/
[17:12:45 INF] Server started. Press Ctrl-C to exit...

This way of displaying endpoints and other user-targeted information as log messages can be confusing. These should be displayed separately from other log messages for clarity.

Expected Behavior

In Debug mode, users shouldn't be forced to specify extra input parameters just to see useful information on the console. The goal is to keep things simple and user-friendly. Moreover, information intended for the console shouldn't be mixed up with other log messages. Let's check the ideal console outputs for both ConsoleReferenceServer and ConsoleReferenceClient.

ConsoleReferenceServer

The ConsoleReferenceServer should present console output destined for informing the user, similar to:

.NET Core OPC UA Reference Server
OPC UA library: 1.5.377.22 @ 11/14/2025 14:29:09 -- 1.5.377.22+c09d97c3af
Loading configuration from Quickstarts.ReferenceServer.
Check the certificate.
Start the server.
opc.tcp://c-w-sum2:62541/Quickstarts/ReferenceServer
opc.https://c-w-sum2:62540/Quickstarts/ReferenceServer/
Server started. Press Ctrl-C to exit...

ConsoleReferenceClient

Similarly, ConsoleReferenceClient should display console output like this:

OPC UA Console Reference Client
OPC UA library: 1.5.377.22 @ 11/14/2025 14:29:09 -- 1.5.377.22+c09d97c3af
Connecting to... opc.tcp://localhost:62541/Quickstarts/ReferenceServer
New Session Created with SessionName = Quickstart Console Reference Client
Connected! Ctrl-C to quit.
Reading nodes...
Read Value = {11/14/2025 3:12:45 PM | 11/14/2025 4:02:05 PM | Running | Opc.Ua.BuildInfo | 0 | } , StatusCode = Good
Read Value = StartTime , StatusCode = Good
Read Value = 11/14/2025 3:12:45 PM , StatusCode = Good
Reading Value of NamespaceArray node...
NamespaceArray Value = {http://opcfoundation.org/UA/|urn:c-w-sum2:UA:Quickstarts:ReferenceServer|http://opcfoundation.org/Quickstarts/ReferenceServer|http://test.org/UA/Data/|http://test.org/UA/Data/Instance|http://opcfoundation.org/UA/Boiler/|http://opcfoundation.org/UA/Boiler/Instance|http://test.org/UA/Alarms/|http://test.org/UA/Alarms/Instance|http://opcfoundation.org/UA/Diagnostics|http://samples.org/UA/MemoryBuffer|http://samples.org/UA/MemoryBuffer/Instance}
Writing nodes...
Write Results :
     Good
     Good
     Good
Browsing i=2253 node...
Browse returned 22 results:
     DisplayName = ServerArray, NodeClass = Variable
     DisplayName = NamespaceArray, NodeClass = Variable
     DisplayName = UrisVersion, NodeClass = Variable
     DisplayName = ServerStatus, NodeClass = Variable
     DisplayName = ServiceLevel, NodeClass = Variable
     DisplayName = EstimatedReturnTime, NodeClass = Variable
     DisplayName = LocalTime, NodeClass = Variable
     DisplayName = ServerCapabilities, NodeClass = Object
     DisplayName = ServerDiagnostics, NodeClass = Object
     DisplayName = VendorServerInfo, NodeClass = Object
     DisplayName = ServerRedundancy, NodeClass = Object
     DisplayName = Namespaces, NodeClass = Object
     DisplayName = ServerConfiguration, NodeClass = Object
     DisplayName = ServerLog, NodeClass = Object
     DisplayName = PublishSubscribe, NodeClass = Object
     DisplayName = Dictionaries, NodeClass = Object
     DisplayName = Resources, NodeClass = Object
     DisplayName = Boilers, NodeClass = Object
     DisplayName = Data, NodeClass = Object
     DisplayName = DefaultHEConfiguration, NodeClass = Object
     DisplayName = Quantities, NodeClass = Object
     DisplayName = DefaultHAConfiguration, NodeClass = Object
Calling UAMethod for node ns=2;s=Methods_Add ...
Method call returned 1 output argument(s):
     OutputValue = 20.5
Calling UAMethod for node ns=7;s=Alarms.Start ...
Method call returned 0 output argument(s):

Steps To Reproduce

No response

Environment

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

Anything else?

No response

In summary, these changes aim to streamline the user experience and ensure that the console output is clear, concise, and informative. Keeping the console clean and avoiding mixing it with log messages makes it easier for developers and users to quickly grasp what's happening with their OPC UA applications. So, stay tuned for updates and improvements in the UA-.NETStandard framework!