I’m writing a code that reads data from an OPC server. This is a summary:

url = opc.tcpXXXXX
client = Client(url)
client.connect()

And then in a while loop I want to read data from the server for several days:

While True:
Data1 =client.get_node(“ns=4;i=3”)
Data1_Val = Data1.get_value()
#write it to sql table
time.sleep(120)

I’m reading 20 nodes the same way in the same while loop.
At first, all works fine. But, after a while the script would still be running but without any data acquisition! What I mean is that after about 2 hours, I will no longer get data from the server.
What could possibly be the problem?
Thanks!
That will be really difficult to say with so less information…
Anyway if you want to often read the value of a bunch of nodes from the server, you should use the OPC UA subscription.
This will be more efficient and you shouldn’t miss any value
Python OPC-UA client stops reading after a while