Discovery
OpcUaDiscovery This is a static class that can be called without a session. It is used for "pre-connection detection":
Subpage Redirect
- To list all endpoints for a specific server, please refer to GetEndpoints.
- To list all servers in LDS the domain, see FindServers.
API
Both methods are methods OpcUaDiscovery of public static, No session required; no instance required:
public static IReadOnlyList<EndpointDescription> GetEndpoints(
string endpointUrl, uint timeoutMs = 10_000);
public static IReadOnlyList<ApplicationDescription> FindServers(
string endpointUrl, uint timeoutMs = 10_000);
| Methods | Category | Reading and Writing | Note |
|---|---|---|---|
| OpcUaDiscovery.GetEndpoints(endpointUrl, timeoutMs) | Discovery | Read | List all resources published by this endpoint EndpointDescription |
| OpcUaDiscovery.FindServers(endpointUrl, timeoutMs) | Discovery | Read | By LDS listing all domains within the domain ApplicationDescription |
The parts where their behaviors are consistent:
endpointUrlnull / empty string →ArgumentNullException;- One-time only TCP → Hello/Ack → OPN(None) → Request → CLO, no session established;
- Returns a value other than
StatusCode.Good→ throwsOpcUaException, i.e.ex.StatusCode, the server's return value; - The result list may be empty (
Array.Empty), and no exception is thrown.
Usage Patterns
using System;
using System.Linq;
using DarraOpcUa_Client;
// 1. First, GetEndpoints check which combinations are supported by the server
var endpoints = OpcUaDiscovery.GetEndpoints("opc.tcp://server:4840", timeoutMs: 10_000);
// 2. Choose a matching one (e.g., SignAndEncrypt + Username)
var ep = endpoints.First(e =>
e.SecurityMode == MessageSecurityMode.SignAndEncrypt &&
e.UserTokens.Any(t => t.TokenType == UserTokenType.Username));
// 3. Use the selected endpoint to establish an actual connection
var (pfxPath, pfxPassword) = CertificateManager.EnsureClientCertificate();
using var ua = new DarraOpcUa(
endpointUrl: ep.EndpointUrl,
securityMode: ep.SecurityMode,
securityPolicyUri: ep.SecurityPolicyUri,
username: "operator", password: "secret",
clientCertPath: pfxPath,
clientKeyPath: pfxPassword, // Enter PFX the password here—not the path to the private key file.
serverCertPath: null); // Leave blank = Automatically GetEndpoints retrieve the server certificate (see the Security page)
ua.Connect();