Home > other >  Python opc ua client how to connect automatically, no overtime break line, no alarm out.
Python opc ua client how to connect automatically, no overtime break line, no alarm out.

Time:10-13

Hi,
I design a opc ua in Python client,
The following code 1,
But, in the process of operation, if didn't start, OPC UA server program will happen to the following error message "1", "
If midway stop, OPC UA server program will happen to the following error message "2" timeout error,

I think the effect of: this code at run time, when OPC UA server did not start, waiting for the link, when OPC UA stops, is also waiting for the link, don't complain,






The program code # 1
The import time
The from opcua import Client
The from opcua import ua

The opc client=client (". TCP://WIN - G9KK36SKPQC: 37800 ")
Client. The connect ()


While True:
# read variable node
Ret=client. Get_node (" ns=1; S=T1 ")
Ret2=client. Get_node (" ns=1; S="D2)
Print (ret) get_value ())
Print (ret2. Get_value ())
Time. Sleep (1)

Client. Disconnect ()


Error message 1:
Traceback (the most recent call last) :
File "C: \ Users \ \ Administrator \ \ Desktop \ \ new folder OPC test combining \ NewTryTest variable node. Py", line 11, the in & lt; module>
Client. The connect ()
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ client \ client py", line 255, in the connect
Self. Connect_socket ()
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ client \ client py", line 280, in connect_socket
Self. Uaclient. Connect_socket (self. Server_url. The hostname, the self. The server_url. Port)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ client \ ua_client py", line 245, in connect_socket
Return the self. _uasocket. Connect_socket (host, port)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ client \ ua_client py", line 142, in connect_socket
The sock=socket. Create_connection ((host, port), timeout=self. The timeout)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ socket py", line 724, in create_connection
Raise err
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ socket py", line 713, in create_connection
The sock. Connect (sa)
ConnectionRefusedError: [10061] WinError because the target machine actively refused, unable to connect,


Error message 2:
Traceback (the most recent call last) :
File "C: \ Users \ \ Administrator \ \ Desktop \ \ new folder OPC test combining \ NewTryTest variable node. Py", line 18, in & lt; module>
Print (ret) get_value ())
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ common \ node py", line 153, in get_value
Result=self. Get_data_value ()
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ common \ node py", line 162, in get_data_value
Return the self. Get_attribute (ua) AttributeIds) Value)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ common \ node py", line 273, in get_attribute
Result=self. Server. Read (params)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ client \ ua_client py", line 326, in the read
Data=https://bbs.csdn.net/topics/self._uasocket.send_request (request)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ site - packages \ opcua \ client \ ua_client py", line 78, in send_request
Data=https://bbs.csdn.net/topics/future.result (self. The timeout)
The File "D: \ \ Program Files \ Python3.6.3 \ lib \ concurrent \ futures \ _base py", line 434, result in
Raise TimeoutError ()
Concurrent. Futures. _base TimeoutError

CodePudding user response:

The building Lord, I also have this question, do you get this problem solved
  • Related