FreeOpcUa / python-opcua

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

Duplicate endpoint when restarting server #1511

Open VasilyBroze opened 1 year ago

VasilyBroze commented 1 year ago

Hello, I try to start-stop-start server, and then I see two endpoints.

image

What I am doing wrong ? Thank you.

server = Server()
    server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
    uri = "http://examples.freeopcua.github.io"
    idx = server.register_namespace(uri)
    objects = server.get_objects_node()
    myobj = objects.add_object(idx, "MyObject")
    myvar = myobj.add_variable(idx, "MyVariable", 6.7)
    myvar.set_writable()  # Set MyVariable to be writable by clients
    server.start()
    try:
        count = 7.5
        while True:
            time.sleep(1)
            count += 0.1
            myvar.set_value(count)
            print(count)
            if round(count, 1) == 8:
                server.stop()
                print("stop")

            if round(count, 1) == 9:
                server.start()
                print("start")