class documentation

class RemoteServer(BaseServer[RemoteUaObject], UaDataChangeSubscriber):

Constructor: RemoteServer(url, username, password, application_uri, ...)

View In Hierarchy

The remote interface for a server-side Server.

After connecting to a server for the first time, its address space needs to be browsed. If your application only requires certain parts of the address space, i.e. only components, you can skip unnecessary browsing by setting the browse_* options of the constructor accordingly. This will speed up the browsing phase of the connection.

Note

Due to an asyncua limitation, custom data types are stored globally. Connections to servers with conflicting custom data types need isolation!

Async Method __aenter__ Enter the asynchronous context manager, connecting to the remote server.
Async Method __aexit__ Exit the asynchronous context manager, disconnecting from the remote server.
Method __init__ Create a new RemoteServer. Does not connect, call connect (or use async with) for that.
Async Method connect Connect to the remote server, retrying if necessary (with Exponential backoff).
Async Method disconnect Disconnect from the remote server.
Async Method ua_on_data_change Undocumented
Class Variable custom_type_definitions Undocumented
Instance Variable init_exceptions EXPERIMENTAL! List of collected exceptions that were not raised during initialization.
Instance Variable logger Undocumented
Instance Variable status_changed Fired each time the status of the remote server is changed.
Instance Variable subscription_manager Undocumented
Instance Variable time_updated Fired each time the remote server time updates. Can be used for checking if the connection is alive.
Property browse_rules Browse rules for automatically recursively browsing the remote server.
Property connected Whether we are currently connected to the remote machine.
Property machines Provide all available machines in dictionary form using the name of the machine as the key.
Property path Always /.
Property status Return the status of the client.
Property ua_client Return the internal OPC UA client. Make sure you know what you are doing.
Property username Username used to connect to the remote server.
Async Method _browse_machines Iterate through all machines.
Async Method _cancel_state_update_task Undocumented
Async Method _connect Undocumented
Async Method _connect_and_retry Undocumented
Async Method _init_machine Undocumented
Async Method _set_security Undocumented
Async Method _set_status Undocumented
Async Method _setup_subscriptions Undocumented
Async Method _status_update_loop Undocumented
Async Method _teardown Best-effort return to DISCONNECTED. Safe to call repeatedly.
Async Method _write_ua_client_state Undocumented
Instance Variable _application_uri Undocumented
Instance Variable _browse_rules Undocumented
Instance Variable _connect_task Undocumented
Instance Variable _disconnect_requested Undocumented
Instance Variable _machines Undocumented
Instance Variable _security_policy Undocumented
Instance Variable _state_update_task Undocumented
Instance Variable _status Undocumented
Instance Variable _suppress_connected Used to suppress CONNECTED before BROWSING state from ua client.
Instance Variable _ua_client Undocumented
Instance Variable _ua_client_state_subscription Undocumented
Instance Variable _username Undocumented
async def __aenter__(self) -> Self:

Enter the asynchronous context manager, connecting to the remote server.

async def __aexit__(self, exc_type, exc, tb):

Exit the asynchronous context manager, disconnecting from the remote server.

def __init__(self, url: str, *, username: str, password: str, application_uri: str | None = None, timeout: float = 10.0, watchdog_interval: float = 1.0, auto_reconnect: bool = True, reconnect_max_delay: float = 30.0, reconnect_request_timeout: float = 60.0, security_policy: SecurityPolicyType = SecurityPolicyType.NoSecurity, browse_rules: Iterable[BrowseRule] | None = None, ua_publishing_interval_ms: int = 100):

Create a new RemoteServer. Does not connect, call connect (or use async with) for that.

Parameters
url:strURL of the OPC UA server to connect to, e.g. opc.tcp://localhost:4843/
username:strUsername for authenticating with the server.
password:strPassword for authenticating with the server.
application_uri:str | NoneGlobally unique application URI identifying this client (also used in the certificate when a security policy is set). A random urn:uuid:... is generated if None.
timeout:floatTimeout in seconds for connection tries.
watchdog_interval:floatInterval in seconds between connection liveness checks.
auto_reconnect:boolWhether to automatically reconnect when the connection to the server is lost.
reconnect_max_delay:floatHow many seconds maximum to wait before reconnect (Exponential backoff).
reconnect_request_timeout:floatHow long requests block waiting for the connection to be ready.
security_policy:SecurityPolicyTypeOPC UA security policy used for the connection. Default: No security policy.
browse_rules:Iterable[BrowseRule] | NoneThe browse rules for automatic browsing. Browse everything by default (None), an empty iterable means browse nothing.
ua_publishing_interval_ms:intRequested publishing interval, in milliseconds, for internal OPC UA subscriptions. May be revised by the server.
async def connect(self, *, max_retries: int | None = 3, min_delay_seconds: float = 0.5, max_delay_seconds: float = 30.0) -> Self:

Connect to the remote server, retrying if necessary (with Exponential backoff).

Parameters
max_retries:int | NoneHow many times to retry connecting to the remote server. None means unlimited.
min_delay_seconds:floatHow many seconds to wait minimum before next reconnection attempt.
max_delay_seconds:floatHow many seconds to wait maximum before next reconnection attempt.
Returns
SelfUndocumented
Raises
ConnectionErrorif connection could not be established after max_retries.
async def disconnect(self):

Disconnect from the remote server.

@override
async def ua_on_data_change(self, node: Node, val: Any, data: DataChangeNotif):

Undocumented

custom_type_definitions: ClassVar[dict[str, type]] =

Undocumented

init_exceptions: list[Exception] =

EXPERIMENTAL! List of collected exceptions that were not raised during initialization.

logger =

Undocumented

status_changed =

Fired each time the status of the remote server is changed.

subscription_manager =

Undocumented

time_updated =

Fired each time the remote server time updates. Can be used for checking if the connection is alive.

@property
browse_rules: tuple[BrowseRule, ...] =

Browse rules for automatically recursively browsing the remote server.

@property
connected: bool =

Whether we are currently connected to the remote machine.

@property
machines: dict[str, RemoteMachine] =

Provide all available machines in dictionary form using the name of the machine as the key.

@property
path: PurePosixPath =

Always /.

@property
status: RemoteServerStatus =

Return the status of the client.

@property
ua_client: Client =

Return the internal OPC UA client. Make sure you know what you are doing.

@property
username: str =

Username used to connect to the remote server.

async def _browse_machines(self):

Iterate through all machines.

async def _cancel_state_update_task(self):

Undocumented

async def _connect(self):

Undocumented

async def _connect_and_retry(self, *, max_retries: int | None = 3, min_delay_seconds: float = 0.5, max_delay_seconds: float = 30.0):

Undocumented

async def _init_machine(self, machine: RemoteMachine):

Undocumented

async def _set_security(self):

Undocumented

async def _set_status(self, status: RemoteServerStatus):

Undocumented

async def _setup_subscriptions(self):

Undocumented

async def _status_update_loop(self) -> Never:

Undocumented

async def _teardown(self):

Best-effort return to DISCONNECTED. Safe to call repeatedly.

async def _write_ua_client_state(self, ua_client_state: UaClientState):

Undocumented

_application_uri: str =

Undocumented

_browse_rules: tuple[BrowseRule, ...] =

Undocumented

_connect_task: asyncio.Task | None =

Undocumented

_disconnect_requested: bool =

Undocumented

_machines: dict[str, RemoteMachine] =

Undocumented

_security_policy =

Undocumented

_state_update_task: Task[Never] | None =

Undocumented

_status =

Undocumented

_suppress_connected: bool =

Used to suppress CONNECTED before BROWSING state from ua client.

_ua_client =

Undocumented

_ua_client_state_subscription =

Undocumented

_username: str =

Undocumented