Replies: 1 comment 1 reply
-
tbh your in the wrong repo ^^ this is the asyncio version of python-opcua import time
from opcua import Client
if __name__ == "__main__":
attempt = 0
client = Client("opc.tcp://localhost:4840/freeopcua/server/")
while 1:
try:
client.connect()
break
except Exception as e:
attempt += 1
print(f"Connection attempt: {attempt}, Error: {e}")
time.sleep(2) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear all,
I'm calling the client.py in a script to connect to a siemens PLC and get data from it.
The PC is starting faster than the plc and so, my python script starts before the OPC UA connection is ready.
I would like to retry to connect with a loop but it fails as the client.py raise exceptions.
Is there anyway to do it no matter when the connection as not started or it has been lost?
I'm new to python, so your help will be very valuable and appreciated.
import os, datetime, time
from goto import goto, label
from opcua import Client
#Boucle infinie
while True:
Beta Was this translation helpful? Give feedback.
All reactions