fix: Remove explicit security policy setting from OPC UA client

Let the client automatically negotiate security policy with the server instead of trying to set it explicitly
This commit is contained in:
openhands 2025-11-01 20:03:20 +00:00
parent 2bad8c9ea0
commit 9c92c5c47f
1 changed files with 4 additions and 1 deletions

View File

@ -23,12 +23,15 @@ class OPCUAClient:
"""Connect to OPC UA server.""" """Connect to OPC UA server."""
try: try:
from asyncua import Client from asyncua import Client
from asyncua.crypto.security_policies import SecurityPolicyBasic256Sha256
self._client = Client(url=self.endpoint) self._client = Client(url=self.endpoint)
# Explicitly set security policy to match server configuration # Explicitly set security policy to match server configuration
# The server supports both Basic256Sha256 and None security policies # The server supports both Basic256Sha256 and None security policies
# Use None for development/testing # Use None for development/testing
await self._client.set_security_string("http://opcfoundation.org/UA/SecurityPolicy#None") # Try connecting without explicit security policy first
# The client should automatically negotiate with the server
# Set timeout for connection # Set timeout for connection
await asyncio.wait_for(self._client.connect(), timeout=5.0) await asyncio.wait_for(self._client.connect(), timeout=5.0)