FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.36k stars 658 forks source link

How to check if OPC UA Server is active or not.? #500

Open SAndrew27 opened 7 years ago

SAndrew27 commented 7 years ago

Hi all

I have OPC UA server which runs fine and I am able to connect and get all the values as well. I am following the client minimal example to connect to the server. Now server sometimes goes offline and after like 5-10mins it comes back online.

Now as per the example of client minimal, when the server is online, it runs the try{} block and when the server goes offline if runs finally{} and disconnect from the client. Now here when the server is back online again how would the client know that the server is active and will try to connect to it.

Is there any method/function available which a client can use to check if the server is active or not. Something like

while True:
    #keep checking if server is active
    status = server.is_alive()

    #If server is active,connect to it
     if status is 1:
        print("Server is active)
        #client.connect and other code goes here

     #If server is not active, disconnect and check if its active again
     else:
        print("Server is inactive)
zerox1212 commented 7 years ago

From what I remember auto-reconnect is not implemented.