![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
03/13/2024
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Goodday, everyone!
I need your help. I need to write a C++ program that can get and set values from/to variables of the program run on a PLC.
The manufaturer of the PLC told me they use Modbus RTU and OPC UA data transfer protocols to connect it to PLC programming software CODESYS. The data I need to change is transferred via OPC UA so I built QtOpcUa module (https://doc.qt.io/qt-5/qtopcua.....index.html) and added it to my project. I studied these examples of how to make a client: https://doc.qt.io/qt-5/qtopcua.....mples.html. The three programs from here (client, server, viewer) all work great but when I tried to change example server's IP to my PLC's IP QtCreator failed to succeed. What's more: this viewer also failed to get a tree of nodes from PLC's loaded program.
However, when I tried to use another software developer's OPC UA client UaExpert (https://www.unified-automation.....ients.html) it read nodes of both the example server and my PLC. So its values can be read and changed dynamically what I found out using it. I just don't understand why that first client can't see it as well as my program based entirely on the client example?
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
03/13/2024
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
I'm not quite sure where to find status info about CreateSession and ActivateSession. Should it be written in the console output? Then there's no mentions of it when I launch the viewer and try to connect to my PLC:
11:32:07: Starting C:\Qt\5.15.2\mingw81_64\qtopcua\examples\opcua\opcuaviewer\debug\opcuaviewer.exe...
Creating PKI path 'C:/Qt/5.15.2/mingw81_64/qtopcua/examples/opcua/opcuaviewer/debug..//pki/trusted/certs': FAILED.
qt.opcua.security: No client certificate found at "C:/Qt/5.15.2/mingw81_64/qtopcua/examples/opcua/opcuaviewer/debug..//pki/own/certs/opcuaviewer.der" . Application identity will be invalid.
Discovering servers on "opc.tcp://192.168.0.10:4840"
[2024-03-15 11:32:22.543 (UTC+0300)] info/client SecurityPolicy not specified -> use default #None
[2024-03-15 11:32:22.543 (UTC+0300)] warn/securitypolicy Security policy None is used to create SecureChannel. Accepting all certificates
[2024-03-15 11:32:22.546 (UTC+0300)] info/client TCP connection established
[2024-03-15 11:32:22.554 (UTC+0300)] info/client Opened SecureChannel with SecurityPolicy https://opcfoundation.org/UA/SecurityPolicy#None
Failed to retrive endpoints from with status BadConnectionClosed
[2024-03-15 11:32:25.871 (UTC+0300)] info/client SecurityPolicy not specified -> use default #None
[2024-03-15 11:32:25.871 (UTC+0300)] warn/securitypolicy Security policy None is used to create SecureChannel. Accepting all certificates
[2024-03-15 11:32:25.871 (UTC+0300)] warn/network Server url is invalid:
[2024-03-15 11:32:25.871 (UTC+0300)] error/client Opening the TCP socket failed
Screenshot:
And this is the console log I get when successfully connecting to the example sever:
11:38:26: Starting C:\Qt\5.15.2\mingw81_64\qtopcua\examples\opcua\opcuaviewer\debug\opcuaviewer.exe...
Creating PKI path 'C:/Qt/5.15.2/mingw81_64/qtopcua/examples/opcua/opcuaviewer/debug..//pki/trusted/certs': FAILED.
qt.opcua.security: No client certificate found at "C:/Qt/5.15.2/mingw81_64/qtopcua/examples/opcua/opcuaviewer/debug..//pki/own/certs/opcuaviewer.der" . Application identity will be invalid.
Discovering servers on "opc.tcp://127.0.0.1:43344"
[2024-03-15 11:38:37.872 (UTC+0300)] info/client SecurityPolicy not specified -> use default #None
[2024-03-15 11:38:37.872 (UTC+0300)] warn/securitypolicy Security policy None is used to create SecureChannel. Accepting all certificates
[2024-03-15 11:38:37.874 (UTC+0300)] info/client TCP connection established
[2024-03-15 11:38:37.874 (UTC+0300)] info/client Opened SecureChannel with SecurityPolicy https://opcfoundation.org/UA/SecurityPolicy#None
[2024-03-15 11:38:40.207 (UTC+0300)] info/client SecurityPolicy not specified -> use default #None
[2024-03-15 11:38:40.207 (UTC+0300)] warn/securitypolicy Security policy None is used to create SecureChannel. Accepting all certificates
[2024-03-15 11:38:40.211 (UTC+0300)] info/client TCP connection established
[2024-03-15 11:38:40.212 (UTC+0300)] info/client Opened SecureChannel with SecurityPolicy https://opcfoundation.org/UA/SecurityPolicy#None
Client state changed QOpcUaClient::Connecting
[2024-03-15 11:38:42.359 (UTC+0300)] info/client Connecting to endpoint opc.tcp://nf-99-83:43344/
[2024-03-15 11:38:42.359 (UTC+0300)] info/client SecurityPolicy not specified -> use default #None
[2024-03-15 11:38:42.359 (UTC+0300)] warn/securitypolicy Security policy None is used to create SecureChannel. Accepting all certificates
[2024-03-15 11:38:42.359 (UTC+0300)] info/client TCP connection established
[2024-03-15 11:38:42.361 (UTC+0300)] info/client Opened SecureChannel with SecurityPolicy https://opcfoundation.org/UA/SecurityPolicy#None
[2024-03-15 11:38:42.361 (UTC+0300)] info/client Endpoint and UserTokenPolicy unconfigured, perform GetEndpoints
[2024-03-15 11:38:42.361 (UTC+0300)] info/client Found 1 endpoints
[2024-03-15 11:38:42.361 (UTC+0300)] info/client Endpoint 0 has 2 user token policies
[2024-03-15 11:38:42.361 (UTC+0300)] info/client Selected Endpoint opc.tcp://nf-99-83:43344/ with SecurityMode None and SecurityPolicy https://opcfoundation.org/UA/SecurityPolicy#None
[2024-03-15 11:38:42.361 (UTC+0300)] info/client Selected UserTokenPolicy open62541-anonymous-policy with UserTokenType Anonymous and SecurityPolicy https://opcfoundation.org/UA/SecurityPolicy#None
Client state changed QOpcUaClient::Connected
Screenshot:
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
03/13/2024
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Well, yes, it is null. At least very likely to be so: the third dropdown in the first picture shows empty space after pushing "Find Servers" button. When in the second pic it catches the IP of the computer with a local process with server-example running and changes it to the name of the computer "nf-99-83". I don't understand why the third dropdown is empty when I'm connecting to the PLC launched as a OPC UA server while not empty when connecting to the computer process with this server-example.
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
You need to look at what is coming back from the FindServers and GetEndpoints calls.
These results are being used to populate the dialog.
A common problem for clients is they do not have DNS configured so the domain name in the URL cannot be used.
Clients are expected to replace the domain in the URL with a domain/ip address that is known to work before connecting.
This should produce a domain mismatch error which has to be ignored when DNS is not functional on a network.
In a production system you need to configure servers to use the IP and not the hostname if there is no DNS or enable a DNS.
1 Guest(s)