Why do I get a "Check if hostname can be resolved" or "Not enough input arguments" error when connecting to an OPC UA server from MATLAB?

2 views (last 30 days)
When establishing a connection to an OPC UA server, MATLAB shows the following error in R2022b and earlier:
uaclient = opcua('12.34.56.789') Error using strncmpi Not enough input arguments. Error in opc.ua.Client (line 387)             if ~strncmpi(this(tI).Hostname, urlParts.Hostname, numel(this(tI).Hostname)) Error in opcua (line 46) uaObj = opc.ua.Client(varargin{:});
In R2023a and newer:
Could not receive endpoint from URL <...>. Check if hostname can be resolved.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Sep 2024
This issue happens when hostname to IP conversion doesn't occur in the Windows OS. Try the following steps:
1. Navigate to the following path in your Windows Explorer: C:\Windows\System32\drivers\etc\hosts
2. Open the file "hosts".
3. At the bottom of the file "hosts" where there are no "#" symbols, type in the hostname & IP pair for your server. There should be a space between "hostname" and the IP address. It should look something like this:  
12.34.56.789 hostname.domainname.com
This may help MATLAB locate your server.
4. You can then try calling 'opcua' like this:
client = opcua('12.34.56.789', 63500)
Replacing "12.34.56.789" with your server's IP address.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!