get_endpoints
Preliminary / Supporting
- After dragging it to the Endpoint, use Constructor Actually establish a session.
- For cross-service discovery, please use find_servers.
Signature
@staticmethod
def get_endpoints(endpoint_url: str,
timeout_ms: int = 10_000) -> List[EndpointDescription]: ...
Connect to the server using temporary SecureChannel (None mode), complete the sequence TCP → Hello/Ack → OPN(None) → GetEndpoints, and then CLO disconnect. No session required.
Corresponding section of the standard: OPC UA Part 4 §5.4.4 (GetEndpoints).
Parameters
| Parameters | Default | Note |
|---|---|---|
| endpoint_url | — | Target endpoint, such as "opc.tcp://server:4840"; an empty string results in an exception ValueError |
| timeout_ms | 10_000 | Timeout (milliseconds); when 0 is passed, treat it as 10 000 ms |
Returns an empty list (without throwing an exception) if none of the servers have been published List[EndpointDescription].
EndpointDescription Field
| Field | Type | Note |
|---|---|---|
| endpoint_url | Optional[str] | Actual endpoint URL |
| security_mode | MessageSecurityMode | NONE / Sign / SignAndEncrypt |
| security_policy_uri | Optional[str] | Algorithm Suite URI |
| server_application_uri | Optional[str] | Server Applications URI |
| server_product_uri | Optional[str] | Server Products URI |
| server_application_name | Optional[str] | Server Application Name |
| server_application_type | int | 0=Server / 1=Client / 2=ClientAndServer / 3=DiscoveryServer |
| server_certificate | Optional[bytes] | Server Certificate (DER) |
| transport_profile_uri | Optional[str] | Transmission Profile (usually UA-TCP) |
| security_level | int | Server-Side Recommendation Priority |
| user_tokens | List[UserTokenPolicy] | Supported Login Methods |
UserTokenPolicy Field
| Field | Type | Note |
|---|---|---|
| policy_id | Optional[str] | The ID provided by the server, which is sent back when the client is activated |
| token_type | UserTokenType | Anonymous / Username / Certificate / Issued |
Usage
from darra_opcua import OpcUaDiscovery
endpoints = OpcUaDiscovery.get_endpoints("opc.tcp://server:4840")
print(f"Server has {len(endpoints)} endpoints:")
for ep in endpoints:
print(f"\n URL: {ep.endpoint_url}")
print(f" Mode: {ep.security_mode.name}")
print(f" Policy: {ep.security_policy_uri}")
print(f" Tokens:")
for t in ep.user_tokens:
print(f" - {t.token_type.name} (policy_id={t.policy_id})")
Sample Output
Server has 4 endpoints:
URL: opc.tcp://server:4840
Mode: NONE
Policy: http://opcfoundation.org/UA/SecurityPolicy#None
Tokens:
- Anonymous
URL: opc.tcp://server:4840
Mode: Sign
Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
Tokens:
- Anonymous
- Username
URL: opc.tcp://server:4840
Mode: SignAndEncrypt
Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
Tokens:
- Username
- Certificate
The server typically exposes multiple combinations (NONE / Sign / SignAndEncrypt × Anonymous / Username / Certificate), and the client selects the appropriate one based on its needs.
Exception
Always throw an exception on failure OpcUaException; use type e.status_code casting (the value is an enum StatusCode; for codes not included in the enum, retain the original int).
| Exception | status_code | Trigger |
|---|---|---|
ValueError("endpoint_url is required") | — | endpoint_url is empty |
OpcUaException | BadCommunicationError | Unable to connect to the server / Connection lost |
OpcUaException | BadTimeout | timeout_ms No response was received internally |
OpcUaException | BadEncodingError / BadDecodingError | Request encoding or response parsing failed |
OpcUaException | The serviceResult returned by the server | For example, ( BadServiceUnsupported the server does not support Discovery), the original value is passed through |
Implementation Constraints
- Synchronous, blocking call; the timeout is controlled
timeout_msby; The parameter was not removed - Returns a maximum of 256 records
EndpointDescription; if the server returns more than that, only the first 256 records are retrieved, and no error is reported - No Session: The connection is terminated immediately after the request is completed; it does not consume server session quotas, nor does it require prior
connect()
Cross-Language Comparison
| C# | Python | Java | C++ | Rust | C |
|---|---|---|---|---|---|
| GetEndpoints | get_endpoints | getEndpoints | Discovery::GetEndpoints | Discovery::get_endpoints | DarraUa_Discovery_GetEndpoints |