GetEndpoints
- After dragging it to the Endpoint, use Constructor Actually establish a session.
- For cross-service discovery, please use FindServers.
Signature
Static method, defined in DarraOpcUa_Client.OpcUaDiscovery:
public static IReadOnlyList<EndpointDescription> GetEndpoints(
string endpointUrl,
uint timeoutMs = 10_000);
| Parameters | Type | Default | Note |
|---|---|---|---|
| endpointUrl | string | — | Target endpoint, in the form of opc.tcp://server:4840 |
| timeoutMs | uint | 10_000 | Timeout (milliseconds), default 10 seconds |
Send a single request directly to the server GetEndpoints and return the list, No session is required. Single pass TCP → Hello/Ack → OPN(None) → GetEndpoints → CLO.
endpointUrl Thrown when the value is null or an empty string ArgumentNullException; thrown when delivery fails OpcUaException—
ex.StatusCode this is returned by the server StatusCode.
EndpointDescription Field
| Field | Type | Note |
|---|---|---|
| EndpointUrl | string | Actual endpoint URL |
| SecurityMode | MessageSecurityMode | None / Sign / SignAndEncrypt |
| SecurityPolicyUri | string | Algorithm Suite URI |
| ServerCertificate | byte[] | Server Certificate (DER) |
| UserTokens | IReadOnlyList<UserTokenPolicy> | Supported Login Methods |
| TransportProfileUri | string | Transmission Profile (usually UA-TCP) |
| SecurityLevel | byte | Server-Side Recommendation Priority |
| ServerApplicationUri | string | Server-Side Application URI |
| ServerProductUri | string | Server-Side Products URI |
| ServerApplicationName | string | Server Application Name |
| ServerApplicationType | int | Server-Side Application Types |
UserTokenPolicy Field
| Field | Note |
|---|---|
| PolicyId | The ID provided by the server, which is sent back when the client is activated |
| TokenType | Anonymous / Username / Certificate / Issued |
The type of "Issued" tokens, the issuer endpoint, and the token's encryption policy are SDK not currently supported.
Usage
using System;
using DarraOpcUa_Client;
var endpoints = OpcUaDiscovery.GetEndpoints("opc.tcp://server:4840");
Console.WriteLine($"Server has {endpoints.Count} endpoints:");
foreach (var ep in endpoints)
{
Console.WriteLine($"\n URL: {ep.EndpointUrl}");
Console.WriteLine($" Mode: {ep.SecurityMode}");
Console.WriteLine($" Policy: {ep.SecurityPolicyUri}");
Console.WriteLine($" Tokens:");
foreach (var t in ep.UserTokens)
Console.WriteLine($" - {t.TokenType} (PolicyId={t.PolicyId})");
}
Sample Output
(The following PolicyId is a string published by the server itself; the value varies depending on the server.)
Server has 3 endpoints:
URL: opc.tcp://server:4840
Mode: None
Policy: http://opcfoundation.org/UA/SecurityPolicy#None
Tokens:
- Anonymous (PolicyId=anonymous)
URL: opc.tcp://server:4840
Mode: Sign
Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
Tokens:
- Anonymous (PolicyId=anonymous)
- Username (PolicyId=username)
URL: opc.tcp://server:4840
Mode: SignAndEncrypt
Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
Tokens:
- Username (PolicyId=username)
- Certificate (PolicyId=certificate)
The server typically exposes multiple combinations (None / Sign / SignAndEncrypt× Anonymous / Username / Certificate), and the client selects the appropriate one based on its needs.
Exception
| Exception | Trigger Conditions |
|---|---|
ArgumentNullException | endpointUrl null / empty string |
OpcUaException | If the call returns neither a value nor an exception StatusCode.Good, that StatusCode is the server's return value. |
OpcUaException.StatusCode Which type is "Unspecified"? — It could be a network connection issue, the server not supporting Discovery, or a timeout.
Use "On Demand" to display VersionInfo.StatusName(ex.StatusCode) the specific name.