GetEndpoints Failed error when connecting to an OPCUA simulation server

33 views (last 30 days)
I am trying to configure a setup to retrieve data from the IntegrationObject simulation server. I am able to store data in it from a remote host using pyhton. I can also connect to the server as long as I am running MATLAB 2022b in the same host. But when it comes to connect to the server from another remote host using MATLAB 2022b it fires an internal error saying it cannot retrieve the Endpoints
>> s=opcuaserverinfo('u114193')
s =
OPC UA ServerInfo 'Integration Objects UA Server Simulator':
Connection Information:
Hostname: 'u114193'
Port: 62640
Endpoints: [1×5 opc.ua.EndpointDescription]
Security Information:
BestMessageSecurity: SignAndEncrypt
BestChannelSecurity: Basic256Sha256
UserTokenTypes: {'Anonymous' 'Username' 'Certificate'}
>> uac=opcua(s)
uac =
OPC UA Client:
Server Information:
Name: 'Integration Objects UA Server Simulator'
Hostname: 'u114193'
Port: 62640
EndpointUrl: 'opc.tcp://localhost:62640/IntegrationObjects/ServerSimulator'
Connection Information:
Timeout: 10
Status: 'Disconnected'
ServerState: '<Not connected>'
Security Information:
MessageSecurityMode: SignAndEncrypt
ChannelSecurityPolicy: Basic256Sha256
Endpoints: [1×5 opc.ua.EndpointDescription]
>> connect(uac,'opcua_user','mipass')
Error using matlabshared.asyncio.internal.MessageHandler/onError
GetEndpoints Failed.
Error in matlabshared.asyncio.internal.Channel/open (line 275)
obj.ChannelImpl.open(options);
Error in opc.ua.Client/connect (line 567)
clnt.AsyncChannel.open(options);
Username and password are correct. Anonymous access gives the same result. Using the EndpintURL does not help either from the remote host. I have notice that the endpointURL refers to localhost, but the hostname is ok, so I presume It trys to conenect to the remote host.
I can browse the server from any machine using various 3th party OPCUA browsers, Firewall is off
If using the IP of the server, I get the same result, but anyhow, I have updated C:\Windows\System32\drivers\etc\hosts with the correspondig entry for host u114193
I have also followed the instructions to allow DCOM with no security but this prevented my win10 64 bit from booting correctly (https://es.mathworks.com/help/icomm/ug/preparing-to-use-opc-toolbox-software.html)
any hint on this issue will be greatly appreciated?
Best regards.

Answers (2)

Srijith Vijay
Srijith Vijay on 1 Mar 2024
Hi Jose,
This is usually caused by the server returning an endpoint URL that contains an unreachable hostname. Unlike other 3rd party apps, MATLAB does not replace the hostname in the endpoint/discovery URLs returned by the server to prevent secuirty issues.
To help you debug this further, you could use a packet analyzer tool like Wireshark to log OPC UA packets after executing the following command:
uac = opcua("u114193",62640);
Once you have the log, filter the Wireshark log to view only OPC UA packets and then see what is the Endpoint URL received from the server in the "FindServersReponse" and "GetEndpointResponse" packets. See if this contains the expected hostname.
You can refer to this link to setup Wireshark to capture and filter OPC UA packets: Analyzing OPC UA Communications with Wireshark – OPC Connect (opcfoundation.org)
If "u114193" should be the hostname in the endpoint/discovery URLs, then you will need to configure your OPC UA server to return an endpoint/discovery URL that contains this hostname.
  5 Comments
Srijith Vijay
Srijith Vijay on 20 May 2024
Jose,
I meant UA expert would ideally issue a confirmation warning (as below) when you add the server for the first time. Not when you connect an existing client.
Also, replacing "localhost" with your system hostname (u114193) in the endpoint URL information of "opcua" function is not sufficient. There are other inaccessible portions of code that uses the exact endpoint URL containing "localhost" returned by your OPC UA server. This is why the connect function is failing for you eventhough the opcua function goes through.
The issue here stems from the fact that your OPC UA server is configured to return "localhost" instead of "u114193" as hostname, in the endpoint URL it returns. And it would be a secuirty concern fro the MATLAB client to override the endpoint info returned by the server.
I'd recommend reaching out to us at Product Usage (mathworks.com) so that we can help you debug this issue further and possibly fix it.
Meanwhile, you could also try using the machine's IP address instead of hostname in opcua function, after confirming that both localhost and u114193 are mapped to the corresponding machine IP address in etc/hosts file.
Jose
Jose on 23 May 2024
Thank you again for your prompt replay.
Replacing the hostname by its IP address does not help.
I have ended up forwarding the local port the remote opcua server announces (62640 in my case) to the remote host. I just wanted to set up a demostration of the OPCUA capabilities of MATLAB. For these simple and concrete (and academic) test escenario (OPCUA simulation server from integration objects and matlab), this local port forwarding tactic has made, finally, the trick.
For the record, I have used netsh to port fowarding (netsh interface portproxy...). Firewall might need to be adjusted accordingly.
I'm still open to debug this issue further if you think it is helpful, but, as for my use case, I consider it closed.
Thank you again for your help.

Sign in to comment.


Narvik
Narvik on 24 Nov 2023
Edited: Narvik on 1 Mar 2024
Hi,
I understand that you are facing an issue while trying to connect to an OPC server. Retrieving endpoints might fail when the endpoint URL(s) returned by the server is incorrect and the server can't be reached at that address.
You can refer to the following MATLAB answer to avoid issues with retrieving endpoints:
Hope this helps!
  1 Comment
Jose
Jose on 27 Nov 2023
Dear Narvik
thank you for your answer.
I have been unable to locate the service component for Integration Objects Simulation Server...either it does not use an understable name or it is hidden under some type of {FD....}. It seems it does not run as a service either. Regarding your second hint, the error I get is not the same. Moreover, I had already configured the hosts file.
On the other hand, I am able to connect and browse the server from a remote host using 3th party OPCUA clients but not with MATLAB.
Anyhow, I thank you for your help.

Sign in to comment.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!