본문으로 건너뛰기

디스커버리

OpcUaDiscovery 정적 클래스이므로 세션 없이도 호출할 수 있습니다. "연결 전에 먼저 확인"하는 데 사용됩니다:

하위 페이지 이동
  • 특정 서버의 모든 엔드포인트를 나열하려면 다음을 참조하십시오. GetEndpoints.
  • 도메인 내의 LDS 모든 서버를 나열하는 방법은 다음을 참조하십시오. FindServers.

API​

두 방법 모두 OpcUaDiscovery 의 public static 방법이며, 세션이 필요하지 않으며, 인스턴스도 필요하지 않습니다.:

public static IReadOnlyList<EndpointDescription> GetEndpoints(
string endpointUrl, uint timeoutMs = 10_000);

public static IReadOnlyList<ApplicationDescription> FindServers(
string endpointUrl, uint timeoutMs = 10_000);
방법분류읽기 및 쓰기설명
OpcUaDiscovery.GetEndpoints(endpointUrl, timeoutMs)발견읽기해당 엔드포인트에서 공개된 모든 항목을 나열합니다. EndpointDescription
OpcUaDiscovery.FindServers(endpointUrl, timeoutMs)발견읽기[ ]을 통해 도메인 내의 LDS 모든 항목을 나열하여 ApplicationDescription

두 가지의 행동이 일치하는 부분:

  • endpointUrl null / 빈 문자열 → ArgumentNullException;
  • 단 한 번만 수행 TCP → Hello/Ack → OPN(없음) → 요청 → CLO, 세션 생성 없음;
  • 반환값이 StatusCode.Good → (즉 OpcUaException, ex.StatusCode 서버의 반환값);
  • 결과 목록이 비어 있을 수 있습니다 (Array.Empty), 예외는 발생하지 않습니다.

사용 방식​

using System;
using System.Linq;
using DarraOpcUa_Client;

// 1. 먼저 서버에서 어떤 조합을 지원하는지 GetEndpoints 확인합니다.
var endpoints = OpcUaDiscovery.GetEndpoints("opc.tcp://server:4840", timeoutMs: 10_000);

// 2. 일치하는 항목을 하나 선택합니다 (예: SignAndEncrypt + Username)
var ep = endpoints.First(e =>
e.SecurityMode == MessageSecurityMode.SignAndEncrypt &&
e.UserTokens.Any(t => t.TokenType == UserTokenType.Username));

// 3. 선별한 엔드포인트를 사용하여 실제로 연결하기
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, // 여기에는 비밀번호를 PFX 입력하세요. 개인 키 파일의 경로가 아닙니다.
serverCertPath: null); // 비워두기 = 서버 GetEndpoints 인증서를 자동으로 가져오기 (Security 페이지 참조)
ua.Connect();

다음 단계​