Skip to main content

Discovery

OpcUaDiscovery This is a static class (class method) 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 get_endpoints.
  • To list all servers in LDS the domain, see find_servers.

Usage Patterns​

from darra_opcua import OpcUaSession, OpcUaDiscovery, MessageSecurityMode, UserTokenType

# 1. First, get_endpoints check which combinations are supported by the server
endpoints = OpcUaDiscovery.get_endpoints("opc.tcp://server:4840")

# 2. Choose a matching one (e.g., 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. Use the selected endpoint to establish an actual connection
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 Password
ua.connect()

Next Step​