Discovery — обнаружение
OpcUaDiscovery — статический класс (методы класса), вызывается без сессии. Используется, чтобы «сначала проверить, потом подключаться»:
Переход на дочернюю страницу
- Список всех Endpoint одного Server — см. get_endpoints.
- Список всех Server в домене через LDS — см. find_servers.
Модели использования
from darra_opcua import OpcUaSession, OpcUaDiscovery, MessageSecurityMode, UserTokenType
# 1. Сначала get_endpoints — какие комбинации поддерживает сервер
endpoints = OpcUaDiscovery.get_endpoints("opc.tcp://server:4840")
# 2. Выбрать подходящую (например, SignAndEncrypt + Username)
ep = next(e for e in endpoints
if e.security_mode == MessageSecurityMode.SignAndEncrypt
and any(t.token_type == UserTokenType.Username for t in e.user_tokens))
# 3. Реальное подключение по выбранному Endpoint
with OpcUaSession(
endpoint_url=ep.endpoint_url,
security_mode=ep.security_mode,
security_policy_uri=ep.security_policy_uri,
username="operator", password="secret",
client_cert_path=r"C:\certs\client.pfx",
client_key_path="123456") as ua: # client_key_path = пароль от PFX
ua.connect()