I am trying to test the OPC scripting function to read a tag. I enabled “Anonymous Access” in the OPC UA server settings, all my project tags are visible in the OPC UA tag browser. I copied the tag path of one of the tags and tried to read its value with the following code copied from the scripting examples, which is called in gateway startup script.
I got the problem! Its is the server name “Ignition OPC-UA Server” given in the code snippet of the script function, should not have a hyphen, it should be “Ignition OPC UA Server”! That’s something in the documentation of scripting function to be changed by you guys at IA! The code snippet contains a hyphen in the server name where as the actual OPC UA server name (atleast in version 8) doesn’t have a hyphen! its working fine with that change.
INFO | jvm 1 | 2020/05/20 23:07:08 | Value: 50.0
INFO | jvm 1 | 2020/05/20 23:07:08 | Quality: Good
INFO | jvm 1 | 2020/05/20 23:07:08 | Timestamp: Wed May 20 23:07:08 IST 2020
Yeah… I guess we could update that snippet, but then if your system was an upgrade it would be wrong because upgrades still have the hyphen in the name.
Removing that hyphen in the name of the default/loopback OPC UA connection on new installs of 8 was an unfortunate mistake that didn’t get caught before Ignition 8 was released.
Another strange thing I found , I just tried to increment the value by one and write back to tag and print it. I find the value is not incremented, though , it changes in Tag DB eventually ! So there is a delay . Is it due to write being async!
Does the Ignition OPC UA server provide the subscription function ? Why is it not supported in the scripting library?
Yes, but there's not really a compelling reason to make it available via scripting. Most scripts don't have an appropriate lifecycle to create a monitored item and delete it when they are done, and if you want a continually updated value you can already just access an OPC tag from scripting.
Are all the client methods defined in the spec for client classes implemented in the server?
The spec defines services. The server implements the required ones for the "Standard UA Server" profile.
Is there any sample client code available in java or any other language like python for reference?
Not really sure what you're asking for here. Sample client code to talk an OPC UA server outside of Ignition?
Then your external applications are presumably using some kind of OPC UA toolkit or SDK and you should find code examples that are specific to that SDK.
Ok, that’s what I was also thinking about. I did see the prosys sdk some time back for examples. However you had mentioned on the forum or LinkedIn some python based library. I think it would also be a good reference.
While trying to connect to Ignition OPC UA server with py commands “client=Client(“opc.tcp://127.0.0.1:62541”)” and “client.connect()” on localhost, I get following error:
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
The Ignition server is running on local mode. What could be the problem.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python38\lib\site-packages\opcua\client\client.py", line 272, in connect
self.connect_socket()
File "C:\Python38\lib\site-packages\opcua\client\client.py", line 297, in connect_socket
self.uaclient.connect_socket(self.server_url.hostname, self.server_url.port)
File "C:\Python38\lib\site-packages\opcua\client\ua_client.py", line 256, in connect_socket
return self._uasocket.connect_socket(host, port)
File "C:\Python38\lib\site-packages\opcua\client\ua_client.py", line 155, in connect_socket
sock = socket.create_connection((host, port), timeout=self.timeout)
File "C:\Python38\lib\socket.py", line 808, in create_connection
raise err
File "C:\Python38\lib\socket.py", line 796, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it