CalejoControl/test_server_endpoints.py

49 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Test script to check what endpoints the OPC UA server is actually offering
"""
import asyncio
async def check_server_endpoints():
"""Check what endpoints the server is offering."""
try:
from asyncua import Client
client = Client(url="opc.tcp://localhost:4840")
# Get endpoints without connecting
print("Getting server endpoints...")
endpoints = await client.connect_and_get_server_endpoints()
print(f"\nFound {len(endpoints)} endpoint(s):")
for i, ep in enumerate(endpoints):
print(f"\nEndpoint {i+1}:")
print(f" Endpoint URL: {ep.EndpointUrl}")
print(f" Security Mode: {ep.SecurityMode}")
print(f" Security Policy URI: {ep.SecurityPolicyUri}")
print(f" Transport Profile URI: {ep.TransportProfileUri}")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
async def main():
"""Run the test."""
print("=" * 60)
print("Server Endpoint Check")
print("=" * 60)
await check_server_endpoints()
print("\n" + "=" * 60)
print("Test completed")
print("=" * 60)
if __name__ == "__main__":
asyncio.run(main())