GetEndpoints
사전 준비 / 부대 조치
- Endpoint로 끌어온 후 다음을 사용하여 생성자 세션을 실제로 생성합니다.
- 서비스 간 검색을 하려면 다음을 사용하십시오. FindServers.
서명
정적 메서드, 정의 위치 DarraOpcUa_Client.OpcUaDiscovery:
public static IReadOnlyList<EndpointDescription> GetEndpoints(
string endpointUrl,
uint timeoutMs = 10_000);
| 매개변수 | 유형 | 기본값 | 설명 |
|---|---|---|---|
| endpointUrl | string | — | 대상 엔드포인트, 형식은 다음과 같습니다. opc.tcp://server:4840 |
| timeoutMs | uint | 10_000 | 타임아웃 (밀리초), 기본값 10초 |
서버에 직접 한 번 요청을 보내고 목록을 반환하며 GetEndpoints , 세션을 설정할 필요가 없습니다.. 한 번만 이동 TCP → Hello/Ack → OPN(없음) → GetEndpoints → CLO.
endpointUrl null 또는 빈 문자열일 때 예외 발생 ArgumentNullException; 전송 실패 시 예외 발생 OpcUaException,
ex.StatusCode 이는 서버 측에서 반환된 것입니다 StatusCode.
EndpointDescription 필드
| 필드 | 유형 | 설명 |
|---|---|---|
| EndpointUrl | string | 실제 엔드포인트 URL |
| SecurityMode | MessageSecurityMode | None / Sign / SignAndEncrypt |
| SecurityPolicyUri | string | 알고리즘 패키지 URI |
| ServerCertificate | byte[] | 서버 인증서 (DER) |
| UserTokens | IReadOnlyList<UserTokenPolicy> | 지원되는 로그인 방식 |
| TransportProfileUri | string | 전송 프로필 (일반적으로 UA-TCP) |
| SecurityLevel | byte | 서버 측 추천 우선순위 |
| ServerApplicationUri | string | 서버 애플리케이션 URI |
| ServerProductUri | string | 서버 측 제품 URI |
| ServerApplicationName | string | 서버 애플리케이션 이름 |
| ServerApplicationType | int | 서버 측 애플리케이션 유형 |
UserTokenPolicy 필드
| 필드 | 설명 |
|---|---|
| PolicyId | 서버에서 제공한 ID로, 클라이언트 활성화 시 전송됨 |
| TokenType | Anonymous / Username / Certificate / Issued |
기타 토큰 필드
Issued 유형의 토큰 종류 / Issuer 엔드포인트 / 토큰 자체의 암호화 정책은 현재 SDK 제공되지 않습니다.
사용법
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})");
}
대표적인 출력
(아래는 서버 PolicyId 측에서 직접 공개한 문자열이며, 서버에 따라 값이 다릅니다)
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)
서버 측에서는 일반적으로 여러 가지 조합(None / Sign / SignAndEncrypt × Anonymous / Username / Certificate)을 제공하며, 클라이언트는 필요에 따라 선택합니다.
예외
| 예외 | 발동 조건 |
|---|---|
ArgumentNullException | endpointUrl null / 빈 문자열 |
OpcUaException | 호출 결과가 예외가 아닌 경우 StatusCode.Good, 해당 값이 서버의 반환값입니다 StatusCode . |
OpcUaException.StatusCode '고정되지 않음'은 어떤 경우를 말하는가? —— 네트워크 연결 오류, 서버 측에서 Discovery를 지원하지 않음, 타임아웃 등이 모두 가능하며,
필요에 따라 구체적인 이름을 VersionInfo.StatusName(ex.StatusCode) 표시한다.