Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normal connection -> Communication ends after about 1 hour!! Anyone who knows the exception information below #1484

Open
zeroche72 opened this issue Sep 22, 2022 · 1 comment

Comments

@zeroche72
Copy link

zeroche72 commented Sep 22, 2022

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

@zeroche72 zeroche72 reopened this Sep 22, 2022
@schroeder-
Copy link
Contributor

schroeder- commented Sep 22, 2022

This library is not supported anymore (#1475). Try to migrate to asyncua and if the bug still exists we will look into it in asyncua.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants