Fora.Rti.Admin.Client Programmer's Manual¶
Fora.Rti.Admin.Client is the .NET SDK for building custom management tools, dashboards, monitors, and automation around a running Fora.Rti.Server. It exposes the same administrative contract used by the built-in fora-admin CLI and remote Fora.Rti.Console mode.
Use this guide when you want to write code against the RTI admin HTTP surface. For command-line operation, see the Fora.Rti.Admin user manual.
Table of Contents¶
- Install
- Minimal Client
- HTTP Client Setup
- Authentication
- Status, Health, and Version
- Federations, Federates, and Sessions
- Logs and Streaming
- Snapshots
- Shutdown
- Error Handling
- Using Shared Admin Commands
- Recommended Tool Structure
Install¶
dotnet add package Fora.Rti.Admin.Client
Common namespaces:
using System.Net.Http.Headers;
using Fora.Rti.Admin;
using Fora.Rti.Admin.Commands;
Fora.Rti.Admin.Client is async-first. Keep one HttpClient for the lifetime of your tool or dashboard client.
Minimal Client¶
using Fora.Rti.Admin;
using var http = new HttpClient
{
BaseAddress = new Uri("http://localhost:8080")
};
IRtiAdminClient client = new HttpAdminClient(http);
VersionInfo version = await client.GetVersionAsync();
AdminStatus status = await client.GetStatusAsync();
IReadOnlyList<string> federations = await client.GetFederationsAsync();
Console.WriteLine($"{version.Component} {version.PackageVersion}");
Console.WriteLine($"Healthy: {status.Healthy}, sessions: {status.ActiveSessions}");
Console.WriteLine($"Federations: {string.Join(", ", federations)}");
HTTP Client Setup¶
HttpAdminClient uses the BaseAddress on the supplied HttpClient and calls:
| API | HTTP endpoint |
|---|---|
GetVersionAsync |
GET /version |
IsHealthyAsync |
GET /health |
GetStatusAsync |
GET /admin/status |
GetFederationsAsync |
GET /admin/federations |
GetFederatesAsync |
GET /admin/federates |
GetSessionsAsync |
GET /admin/sessions |
GetLogsAsync |
GET /admin/logs |
StreamLogsAsync |
GET /admin/logs/stream |
SaveSnapshotAsync |
POST /admin/snapshot/{label} |
RestoreSnapshotAsync |
POST /admin/snapshot/{label}/restore |
ShutdownAsync |
POST /admin/shutdown |
Basic setup:
using var http = new HttpClient
{
BaseAddress = new Uri("https://rti-host:8443"),
Timeout = TimeSpan.FromSeconds(15)
};
IRtiAdminClient client = new HttpAdminClient(http);
For ASP.NET Core dashboards, register a typed client:
builder.Services.AddHttpClient<IRtiAdminClient, HttpAdminClient>(http =>
{
http.BaseAddress = new Uri(builder.Configuration["Fora:RtiAdminUrl"]!);
http.Timeout = TimeSpan.FromSeconds(15);
});
Authentication¶
When Fora.Rti.Server has ForaRtiServer:Admin:ApiKey configured, /admin/* endpoints require a bearer token. Attach the token to the HttpClient.
using var http = new HttpClient
{
BaseAddress = new Uri("https://rti-host:8443")
};
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", apiKey);
IRtiAdminClient client = new HttpAdminClient(http);
Prefer https:// when sending an admin token. A bearer token over plain HTTP is visible to anyone who can observe the network path.
/version and /health may remain public depending on server configuration, but /admin/* is protected when the API key is enabled.
Status, Health, and Version¶
Use IsHealthyAsync for quick checks:
bool healthy = await client.IsHealthyAsync(ct);
IsHealthyAsync returns false if the HTTP request fails. It is intentionally suitable for probes and monitors.
Use GetStatusAsync when you need server state:
AdminStatus status = await client.GetStatusAsync(ct);
Console.WriteLine($"Healthy: {status.Healthy}");
Console.WriteLine($"Active sessions: {status.ActiveSessions}");
Console.WriteLine($"Auth enabled: {status.AuthorizationEnabled}");
Console.WriteLine($"Auth service: {status.AuthorizationServiceName}");
Use GetVersionAsync for display and compatibility checks:
VersionInfo version = await client.GetVersionAsync(ct);
Console.WriteLine(version.Component);
Console.WriteLine(version.PackageVersion);
Console.WriteLine(version.Standard);
Console.WriteLine(version.Hla);
Console.WriteLine(version.CapabilityLevel);
Federations, Federates, and Sessions¶
List active federation executions:
IReadOnlyList<string> federations = await client.GetFederationsAsync(ct);
List joined federates:
IReadOnlyList<FederateInfo> federates = await client.GetFederatesAsync(ct);
foreach (var federate in federates)
{
Console.WriteLine($"{federate.Federation}: {federate.Name} ({federate.Type})");
}
List Federate Protocol sessions:
IReadOnlyList<SessionInfo> sessions = await client.GetSessionsAsync(ct);
foreach (var session in sessions)
{
Console.WriteLine(
$"{session.SessionId} online={session.IsOnline} lastSeen={session.LastSeenUtc:O}");
}
DisconnectedAtUtc is populated when the server has observed a session disconnect.
Logs and Streaming¶
Fetch recent logs:
IReadOnlyList<LogEntry> logs = await client.GetLogsAsync(ct: ct);
Fetch logs after a known timestamp:
DateTimeOffset since = DateTimeOffset.UtcNow.AddMinutes(-5);
IReadOnlyList<LogEntry> recent = await client.GetLogsAsync(since, ct);
Stream live logs with Server-Sent Events:
await foreach (LogEntry entry in client.StreamLogsAsync(ct))
{
Console.WriteLine($"[{entry.TimestampUtc:O}] {entry.Level}: {entry.Message}");
}
StreamLogsAsync completes when the server closes the stream or the cancellation token is canceled. If your dashboard needs continuous tailing, wrap it in a reconnect loop with backoff.
while (!ct.IsCancellationRequested)
{
try
{
await foreach (var entry in client.StreamLogsAsync(ct))
Render(entry);
}
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
break;
}
catch (Exception ex)
{
Log.Warning(ex, "Log stream dropped; reconnecting shortly.");
await Task.Delay(TimeSpan.FromSeconds(2), ct);
}
}
Snapshots¶
Save a snapshot:
await client.SaveSnapshotAsync("baseline", ct);
Restore a snapshot:
bool restored = await client.RestoreSnapshotAsync("baseline", ct);
if (!restored)
{
Console.WriteLine("Snapshot not found.");
}
RestoreSnapshotAsync returns false only for a genuine missing snapshot (404). Other server failures throw.
Snapshot labels are URL-escaped by HttpAdminClient, so labels may contain characters that are valid for the server's snapshot store.
Shutdown¶
await client.ShutdownAsync(ct);
This sends a remote shutdown request to the server. Use it only from trusted operator workflows. If the server requires an admin API key, the request must include the bearer token.
Error Handling¶
HttpAdminClient surfaces failures instead of fabricating success values.
| Case | Behavior |
|---|---|
401 / 403 from an admin endpoint |
Throws InvalidOperationException with an authentication-specific message. |
Non-success response from SaveSnapshotAsync or ShutdownAsync |
Throws through EnsureSuccessStatusCode. |
RestoreSnapshotAsync receives 404 |
Returns false. |
RestoreSnapshotAsync receives another non-success status |
Throws. |
| A successful JSON endpoint returns an empty body | Throws InvalidOperationException. |
IsHealthyAsync request fails |
Returns false. |
Typical pattern:
try
{
await client.SaveSnapshotAsync("before-test", ct);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("authentication", StringComparison.OrdinalIgnoreCase))
{
Console.Error.WriteLine("Admin token is missing or invalid.");
}
catch (HttpRequestException ex)
{
Console.Error.WriteLine($"Admin request failed: {ex.Message}");
}
For dashboards, distinguish probe-style calls (IsHealthyAsync) from contract calls (GetStatusAsync, GetSessionsAsync, SaveSnapshotAsync) so operators can see real server errors.
Using Shared Admin Commands¶
The shared abstractions package also contains a small command framework used by the built-in admin tooling. Advanced tools can reuse it when they want CLI-like commands over an IRtiAdminClient.
var registry = new CommandRegistry();
IAdminCommand? command = registry.GetCommand("federations");
if (command is not null)
{
var context = new AdminCommandContext(
Client: client,
Arguments: [],
Output: output,
PreferJson: true,
CancellationToken: ct);
await command.ExecuteAsync(context);
}
For most dashboards and service integrations, call IRtiAdminClient directly. Use the command layer when you are building a command runner, shell, or automation surface that should behave like fora-admin.
Recommended Tool Structure¶
| Class | Responsibility |
|---|---|
AdminClientFactory |
Builds HttpClient, base URL, timeout, and bearer token. |
RtiStatusService |
Polls GetStatusAsync, GetFederationsAsync, and GetSessionsAsync. |
RtiLogTailService |
Owns StreamLogsAsync and reconnect/backoff behavior. |
SnapshotService |
Wraps save/restore operations with operator confirmation and audit logging. |
DashboardViewModel |
Presents DTOs and derived health indicators to UI code. |
Suggested polling cadence:
| Data | Typical Cadence |
|---|---|
| Health | 1-5 seconds |
| Status/session count | 1-5 seconds |
| Federations/federates/sessions | 2-10 seconds |
| Logs | Use StreamLogsAsync; fall back to GetLogsAsync(since) after reconnect |
Keep admin tooling separate from federate SDK code. Fora.Client is for HLA federates; Fora.Rti.Admin.Client is for observing and controlling the RTI server.
Disclaimer¶
See the Disclaimer for usage terms and research-only conditions.
Updated November 18, 2026, 21:47:16 (UTC+03:00)