using AVEVA.Historian.Client.Models;
namespace AVEVA.Historian.Client;
public sealed class HistorianClientOptions
{
public const int DefaultPort = 32568;
/// Default TCP port of the 2023 R2 Historian Client Access Point gRPC endpoint.
public const int DefaultGrpcPort = 32565;
public required string Host { get; init; }
public int Port { get; init; } = DefaultPort;
public TimeSpan ConnectTimeout { get; init; } = TimeSpan.FromSeconds(5);
public TimeSpan RequestTimeout { get; init; } = TimeSpan.FromSeconds(30);
public string UserName { get; init; } = string.Empty;
public string Password { get; init; } = string.Empty;
public bool IntegratedSecurity { get; init; }
public bool Compression { get; init; }
public HistorianConnectionKind ConnectionKind { get; init; } = HistorianConnectionKind.Process;
public HistorianTransport Transport { get; init; } = HistorianTransport.LocalPipe;
public string TargetSpn { get; init; } = @"NT SERVICE\aahClientAccessPoint";
///
/// When true, the WCF channel factories used by the SDK accept the server's
/// X.509 certificate without chain validation. Useful when connecting to a
/// development / on-prem Historian whose /HistCert endpoint presents an
/// installer-generated self-signed cert that isn't in the local trust store
/// (notably .NET WCF on Linux ignores the system CA bundle for its own
/// X509Chain checks). Default false; do not enable in production where the
/// server's identity matters.
///
public bool AllowUntrustedServerCertificate { get; init; }
///
/// Overrides the expected DNS identity in the endpoint address — set this to
/// whatever DNS name the server's certificate actually claims (often
/// localhost on installer-generated AVEVA Historian certificates) when
/// connecting via IP address or a hostname that doesn't match the cert SAN/CN.
/// Without this override WCF rejects the channel with
/// "Identity check failed for outgoing message". Has no effect on transports
/// that don't validate a server certificate.
///
public string? ServerDnsIdentity { get; init; }
///
/// Optional WCF "Via" address (e.g. net.tcp://host:42568). When set, the SDK's WCF
/// channel factories connect to this address while still addressing the SOAP message
/// To the logical endpoint built from /. Use this when
/// the Historian is reached through a port-forwarding tunnel or proxy whose local port differs
/// from the server's real service port: point / at the
/// server's real endpoint (so the server's WCF AddressFilter matches) and set this to the tunnel
/// endpoint. Has no effect on the gRPC transport. Default null (connect == address).
///
public string? ConnectViaAddress { get; init; }
///
/// Diagnostic override for the native OpenConnection mode the WCF event-read chain uses (default
/// 0x402, read-only process). Set to e.g. 0x501 (event) or 0x401 (write-enabled)
/// to probe whether CM_EVENT registration / event-row retrieval needs a different connection type on a
/// 2023 R2 server. Null = the default read-only process mode. Intended for protocol investigation.
///
public uint? EventReadConnectionModeOverride { get; init; }
///
/// For : when true the channel uses TLS
/// (https://); when false it uses plaintext (http://). Matches the stock
/// 2023 R2 client's securedConnection flag. The TLS host is taken from
/// when set (to match the server certificate's name),
/// otherwise . When is
/// true the server certificate chain is not validated. Default false.
///
public bool GrpcUseTls { get; init; }
///
/// When true (default) the SDK verifies, at connect time, that the Historian server
/// reports the native interface versions its byte serializers were built against
/// (History=11, Retrieval=4, Transaction=2 — evidence from a live AVEVA Historian 2020
/// server). A mismatch throws rather than
/// risk misparsing version-framed native buffers. Set false only when you have
/// independently confirmed wire compatibility with a different server version — e.g.
/// when bringing up a 2023 R2 gRPC server whose reported interface integers have not yet
/// been captured. See .
///
public bool VerifyServerInterfaceVersion { get; init; } = true;
}