MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / Client

Class Client

opcua/client/client.py:81–674  ·  view source on GitHub ↗

High level client to connect to an OPC-UA server. This class makes it easy to connect and browse address space. It attempts to expose as much functionality as possible but if you want more flexibility it is possible and advised to use the UaClient object, available as self.uacl

Source from the content-addressed store, hash-verified

79
80
81class Client(object):
82 """
83 High level client to connect to an OPC-UA server.
84
85 This class makes it easy to connect and browse address space.
86 It attempts to expose as much functionality as possible
87 but if you want more flexibility it is possible and advised to
88 use the UaClient object, available as self.uaclient, which offers
89 the raw OPC-UA services interface.
90 """
91
92 if use_crypto is False:
93 logging.getLogger(__name__).warning("cryptography is not installed, use of crypto disabled")
94
95 def __init__(self, url, timeout=4):
96 """
97
98 :param url: url of the server.
99 if you are unsure of url, write at least hostname
100 and port and call get_endpoints
101
102 :param timeout:
103 Each request sent to the server expects an answer within this
104 time. The timeout is specified in seconds.
105
106 Some other client parameters can be changed by setting
107 attributes on the constructed object:
108
109 secure_channel_timeout
110 Timeout for the secure channel, specified in milliseconds.
111
112 session_timeout
113 Timeout for the session, specified in milliseconds.
114
115 See the source code for the exhaustive list.
116 """
117 _logger = logging.getLogger(__name__)
118 self.server_url = urlparse(url)
119 # take initial username and password from the url
120 self._username = self.server_url.username
121 self._password = self.server_url.password
122 self.name = "Pure Python Client"
123 self.description = self.name
124 self.application_uri = "urn:freeopcua:client"
125 self.product_uri = "urn:freeopcua.github.io:client"
126 self.security_policy = ua.SecurityPolicy()
127 self.secure_channel_id = None
128 self.secure_channel_timeout = 3600000 # 1 hour
129 self.session_timeout = 3600000 # 1 hour
130 self._policy_ids = []
131 self.uaclient = UaClient(timeout)
132 self.user_certificate = None
133 self.user_private_key = None
134 self._server_nonce = None
135 self._session_counter = 1
136 self.keepalive = None
137 self.nodes = Shortcuts(self.uaclient)
138 self.max_messagesize = 0 # No limits

Callers 15

wrapperFunction · 0.90
test_find_serversMethod · 0.90
test_find_endpointsMethod · 0.90
uareadFunction · 0.90
uawriteFunction · 0.90
ualsFunction · 0.90
uasubscribeFunction · 0.90
uaclientFunction · 0.90
uadiscoverFunction · 0.90
uahistoryreadFunction · 0.90

Calls

no outgoing calls

Tested by 15

wrapperFunction · 0.72
test_find_serversMethod · 0.72
test_find_endpointsMethod · 0.72
setUpClassMethod · 0.72
test_context_managerMethod · 0.72
setUpClassMethod · 0.72
test_nocryptoMethod · 0.72
test_nocrypto_failMethod · 0.72
test_basic256sha256Method · 0.72