You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I succeeded in connecting Siemens CPU through OPC-UA communication.
(Attach the code below)
However, after a certain period of time, it is terminated after an exception occurs as shown below.
Anyone who knows why please help me
########################### My Code
from opcua import Client
import logging
import time
from datetime import datetime
############################### exception information
ERROR:opcua.client.ua_client.Socket:Protocol Error
Traceback (most recent call last):
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 101, in _run
self._receive()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 112, in _receive
msg = self._connection.receive_from_socket(self._socket)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 363, in receive_from_socket
return self.receive_from_header_and_body(header, ua.utils.Buffer(body))
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 328, in receive_from_header_and_body
self._check_sym_header(security_header)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 276, in _check_sym_header
self.next_security_token.TokenId))
opcua.ua.uaerrors._base.UaError: Invalid security token id 6, expected 5 or 0
ERROR:opcua.client.ua_client.Socket:Protocol Error
Traceback (most recent call last):
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 101, in _run
self._receive()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 112, in _receive
msg = self._connection.receive_from_socket(self._socket)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 363, in receive_from_socket
return self.receive_from_header_and_body(header, ua.utils.Buffer(body))
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 335, in receive_from_header_and_body
return self._receive(chunk)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 366, in _receive
self._check_incoming_chunk(msg)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 311, in _check_incoming_chunk
.format(self._peer_sequence_number, num))
opcua.ua.uaerrors._base.UaError: Wrong sequence 3061 -> 3063 (server bug or replay attack)
Traceback (most recent call last):
File "test.py", line 45, in
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\client.py", line 68, in run
val = server_state.get_value()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 153, in get_value
result = self.get_data_value()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 162, in get_data_value
return self.get_attribute(ua.AttributeIds.Value)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 273, in get_attribute
result = self.server.read(params)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 337, in read
data = self._uasocket.send_request(request)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 83, in send_request
data = future.result(self.timeout)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\concurrent\futures_base.py", line 434, in result
raise TimeoutError()
concurrent.futures._base.TimeoutError
logWrite(str(rst.get_value()))
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 153, in get_value
result = self.get_data_value()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 162, in get_data_value
return self.get_attribute(ua.AttributeIds.Value)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 273, in get_attribute
result = self.server.read(params)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 337, in read
data = self._uasocket.send_request(request)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 83, in send_request
data = future.result(self.timeout)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\concurrent\futures_base.py", line 434, in result
raise TimeoutError()
concurrent.futures._base.TimeoutError
The text was updated successfully, but these errors were encountered:
I succeeded in connecting Siemens CPU through OPC-UA communication.
(Attach the code below)
However, after a certain period of time, it is terminated after an exception occurs as shown below.
Anyone who knows why please help me
########################### My Code
from opcua import Client
import logging
import time
from datetime import datetime
url = "opc.tcp://10.27.176.101:4840"
client = Client(url)
client.set_user("OpcUaClient")
client.set_password("12345678")
client.connect()
while True:
____try:
________ rst = client.get_node("ns=2;s=/Channel/Spindle/driveLoad[1]")
________ print(rst.get_value())
________print('#==================#')
________time.sleep(0.05)
____except(TimeoutError):
________print('-------------------------------------timeout')
________ print(str(TimeoutError)
________continue
############################### exception information
ERROR:opcua.client.ua_client.Socket:Protocol Error
Traceback (most recent call last):
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 101, in _run
self._receive()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 112, in _receive
msg = self._connection.receive_from_socket(self._socket)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 363, in receive_from_socket
return self.receive_from_header_and_body(header, ua.utils.Buffer(body))
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 328, in receive_from_header_and_body
self._check_sym_header(security_header)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 276, in _check_sym_header
self.next_security_token.TokenId))
opcua.ua.uaerrors._base.UaError: Invalid security token id 6, expected 5 or 0
ERROR:opcua.client.ua_client.Socket:Protocol Error
Traceback (most recent call last):
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 101, in _run
self._receive()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 112, in _receive
msg = self._connection.receive_from_socket(self._socket)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 363, in receive_from_socket
return self.receive_from_header_and_body(header, ua.utils.Buffer(body))
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 335, in receive_from_header_and_body
return self._receive(chunk)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 366, in _receive
self._check_incoming_chunk(msg)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\connection.py", line 311, in _check_incoming_chunk
.format(self._peer_sequence_number, num))
opcua.ua.uaerrors._base.UaError: Wrong sequence 3061 -> 3063 (server bug or replay attack)
Traceback (most recent call last):
File "test.py", line 45, in
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\client.py", line 68, in run
val = server_state.get_value()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 153, in get_value
result = self.get_data_value()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 162, in get_data_value
return self.get_attribute(ua.AttributeIds.Value)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 273, in get_attribute
result = self.server.read(params)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 337, in read
data = self._uasocket.send_request(request)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 83, in send_request
data = future.result(self.timeout)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\concurrent\futures_base.py", line 434, in result
raise TimeoutError()
concurrent.futures._base.TimeoutError
logWrite(str(rst.get_value()))
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 153, in get_value
result = self.get_data_value()
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 162, in get_data_value
return self.get_attribute(ua.AttributeIds.Value)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\common\node.py", line 273, in get_attribute
result = self.server.read(params)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 337, in read
data = self._uasocket.send_request(request)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\site-packages\opcua\client\ua_client.py", line 83, in send_request
data = future.result(self.timeout)
File "C:\Users\jm0902.kim\AppData\Local\Programs\Python\Python36\lib\concurrent\futures_base.py", line 434, in result
raise TimeoutError()
concurrent.futures._base.TimeoutError
The text was updated successfully, but these errors were encountered: