Hi @Dauken
The connection test may fail in VC but you can still connect to your server.
Here’s a simple example, tested and works on Python3
import time
from opcua import ua, Server
if __name__ == "__main__":
# setup server
server = Server()
server.set_endpoint("opc.tcp://localhost:4840")
'''
server.set_security_policy([
ua.SecurityPolicyType.NoSecurity,
ua.SecurityPolicyType.Basic256Sha256_SignAndEncrypt,
ua.SecurityPolicyType.Basic256Sha256_Sign
])
'''
# setup our own namespace, not really necessary but should as spec
uri = "http://localhost"
idx = server.register_namespace(uri)
# get Objects node, this is where we should put our nodes
objects = server.get_objects_node()
print(objects)
# populating our address space
myobj = objects.add_object(idx, "MyObject")
myvar = myobj.add_variable(idx, "MyVariable", 6.7)
myvar.set_writable() # Set MyVariable to be writable by clients
print(server.get_namespace_array())
# starting!
server.start()
try:
# count = 0
# while True:
# time.sleep(1)
# count += 0.1
# myvar.set_value(count)
input("Press Enter to shutdown server...\n")
finally:
#close connection, remove subcsriptions, etc
server.stop()
Shows up in VC like this after connecting:
