Why do I get a warning saying " Some endpoints could not be retrieved" using the `opcuaserverinfo` MATLAB function.

11 views (last 30 days)
I get the following warning message when executing the opcuaserverinfo function in the Industrial Communication Toolbox. The resultant opc.ua.Serverinfo object has an empty Endpoints property as well.
Warning: Some endpoints could not be retrieved:
OPCServer@Hostname:
An internal TCP error occurred.
> In opc.ua.getServerInfo (line 76)
In opcuaserverinfo (line 33)
Also, I get the following error when trying to directly connect to the OPC UA sevrer using the opcua function:
Error using opc.ua.Client/fetchEndpoints (line 627)
The hostname could not be resolved.

Accepted Answer

MathWorks Industrial Communication Toolbox Team
This issue arises when the OPC UA Server has certificates with endpoints that cannot be accessed by the client. For e.g. Say the machine hosting the OPC UA server can only be reached at hostname.dhcp.companyname.com, but the OPC UA server certificate includes endpoints with hostname as hostname.companyname.com (without the "dhcp") instead. As a result, we are unable to retreive endpoints with this discovery URL returned by the server.
You can verify this by capturing the OPC UA data packets in an application like Wireshark and viewing the "FindServersResponse" or "GetEndPointsResponse" OPC UA packets.
According to the OPC standard, the OPC UA server is responsible for returning all possible endpoints that the client can discover. Since the server may be accessible through various hostnames (such as IP address, hostname, or multiple IP addresses if multiple network cards are present), the server needs to utilize the hostname provided by the client to construct the appropriate endpoints. It should respond with certificate and endpoint information relevant to the path for which the client requested endpoints.
A short-term solution involves the client "registering" the server's hostname locally along with the network path used to connect to the server. If the DHCP query is for a static IP, the client's HOSTS file can include the IP address and hostname in the Windows\System32\Drivers\etc\hosts file as follows:
172.16.254.43 hostname.companyname.com
Note: Update the IP and hostname above as per your work environment.
In the long run, it is crucial to ensure that the server offers endpoints accessible through all available paths. In a DHCP environment, this means the server should have a static IP on the DHCP network, and the hostname should resolve to that IP address when using that particular route to the server.
UPDATE [6/16/2025]: Starting MATLAB R2025a, you can now replace the endpoint URL hostname with input hostname/IP using the name-value argument UseDiscoveryHostname. For more information, see Create OPC UA Client and Configure Endpoint URL Hostname.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!