メインコンテンツまでスキップ

Discovery 発見

OpcUaDiscovery 静的クラス(クラスメソッド)であり、セッションを必要とせずに呼び出すことができます。「接続前に検出を行う」ために使用されます:

サブページへの移動
  • 特定のサーバーのすべてのエンドポイントを一覧表示するには、以下を参照してください。 get_endpoints.
  • ドメイン内の LDS すべてのサーバーの一覧については、以下を参照してください。 find_servers.

使用パターン​

from darra_opcua import OpcUaSession, OpcUaDiscovery, MessageSecurityMode, UserTokenType

# 1. まず、サーバーがどの組み合わせに対応しているかを確認 get_endpoints する
endpoints = OpcUaDiscovery.get_endpoints("opc.tcp://server:4840")

# 2. 一致するものを選ぶ(例: SignAndEncrypt + ユーザー名)
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. 選定したエンドポイントを使用して実際に接続する
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()

次のステップ​