Skip to main content

Server Information (ReadServerStatus / BuildInfo / ServerState)

Overview​

OPC UA standard node i=2256 (Server.ServerStatus) exposes server runtime information: start time, current time, state, build info, shutdown countdown and shutdown reason. The SDK assembles these 11 child nodes (i=2257 through i=2266, plus i=2992 / i=2993) into a strongly typed ServerStatus object.

Corresponding section of the standard: Part 5 §6.3 (ServerStatusDataType).

API​

Methods / PropertiesCategoryReading and WritingNote
ua.ReadServerStatus()DiagnosisReadReturns the Full List ( ServerStatus 11 nodes at a time RPC)
ua.ReadServerState()DiagnosisReadRead only i=2259, return ServerState enumeration
ua.ReadCurrentTime()DiagnosisReadRead only i=2258, return DateTime (UTC, or default(DateTime) if the operation fails)

All three are extension methods DarraOpcUa of, defined in DarraOpcUa_Client.ServerInfoExtensions.

Related Structures:

public sealed class ServerStatus
{
public DateTime StartTime { get; init; } // Starting the Server UTC
public DateTime CurrentTime { get; init; } // Server Status UTC
public ServerState State { get; init; } // Current Status
public BuildInfo Build { get; init; } // Product/Manufacturer/Version/Build Number/Build Date
public uint SecondsTillShutdown { get; init; } // Seconds remaining until shutdown (usually 0 when "Running")
public string ShutdownReason { get; init; } // Reason for Shutdown (LocalizedText.Text)
}

public sealed class BuildInfo
{
public string ProductUri { get; init; } // i=2262 Unique Product Identifier URI
public string ManufacturerName { get; init; } // i=2263 Manufacturer
public string ProductName { get; init; } // i=2261 Product Name
public string SoftwareVersion { get; init; } // i=2264 Version string
public string BuildNumber { get; init; } // i=2265 Build Number
public DateTime BuildDate { get; init; } // i=2266 Build Date (UTC)
}

public enum ServerState
{
Running = 0, // Normal
Failed = 1, // Fatal Failure
NoConfiguration = 2, // Missing configuration
Suspended = 3, // Paused by Operations
Shutdown = 4, // Shutting Down
Test = 5, // Test Mode
CommunicationFault = 6, // Communication Link Failure
Unknown = 7 // SDK Fallback (Read Failed)
}

Code Example​

using System;
using DarraOpcUa_Client;

using var ua = new DarraOpcUa("opc.tcp://localhost:4840");
ua.Connect();

// 1) Pull them all at once
var status = ua.ReadServerStatus();
Console.WriteLine($"Start = {status.StartTime}");
Console.WriteLine($"Now = {status.CurrentTime}");
Console.WriteLine($"State = {status.State}");
Console.WriteLine($"Build = {status.Build}");
// → "DarraPLC 1.2.3.4 (build 20260420 @ 2026-04-20)"

if (status.State != ServerState.Running)
Console.WriteLine($"服务端非 Running, 倒计时 {status.SecondsTillShutdown}s, 原因: {status.ShutdownReason}");

// 2) Lightweight Heartbeat (Saving RPC)
var st = ua.ReadServerState();
Console.WriteLine(st == ServerState.Running ? "在线" : st.ToString());

// 3) Clock Drift Check — ReadCurrentTime Returns a non-empty value DateTime; if the read fails, it returns `default(DateTime)`
var serverNow = ua.ReadCurrentTime();
if (serverNow != default)
{
var drift = (DateTime.UtcNow - serverNow).TotalMilliseconds;
Console.WriteLine($"客户端 - 服务端时钟差 = {drift:F1} ms");
}

Error Handling​

  • Never returns null — An object ServerStatus ReadServerStatus must be constructed; fields that cannot be read will default to their default values (string = null, DateTime = default(DateTime), uint = 0; the corresponding fields Build of will also be null or their default values).
  • A failure in a single field does not affect the other fields. — Each child node is read individually. Only The "State" field itself A read failure (or a global exception) State occurs only when ServerState.Unknown; for example, even if only fails to read BuildNumber, may still State be Running.
  • Do not throw exceptions (Except for ua == null throw ArgumentNullException) — A network disconnection or session expiration will not result in an exception; instead, it will be represented as State == Unknown + the default values for each field.ReadServerState Similarly, a failure returns Unknown, and a ReadCurrentTime failure returns default(DateTime).
  • Used for business-side interpretation if (status.State == ServerState.Unknown), Do not write status == null — That’s the Eternal Branch.
  • Unknown "Could not read this time" does not mean "the server is in a failed state" — a true server failure is ServerState.Failed.

Best Practices​

  • Diagnostic Panel — One-time ReadServerStatus, Show 6 fields
  • Status Bar — Use ReadServerState (to save bandwidth)
  • Shutdown Alert — Listening SecondsTillShutdown > 0 → Displays a message saying "The server will shut down in N seconds"
  • Do not call it in the subscription callback — Avoid having the callback thread perform RPC

Cross-Language Comparison​

C#PythonJavaC++RustC
ReadServerStatusread_server_statusreadServerStatusReadServerStatusread_server_statusDarraUa_Session_ReadServerStatus
ReadServerStateread_server_statereadServerStateReadServerStateread_server_stateDarraUa_Session_ReadServerState
ReadCurrentTimeread_current_timereadCurrentTimeReadCurrentTimeread_current_timeDarraUa_Session_ReadCurrentTime

Next Step​