GetEndpoints Failed error when connecting to an OPCUA simulation server

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.

Réponses (2)

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 commentaires

Dear Mr Vijay
First thing off, thank you for your kind answer and sorry for the delay in the replay.
I have run the very same test using Matlab as client and then UaExpert. I can browse the data using UaExpert, but cannot connect with Matlab
When runiing MATLAB FindServerResponse returns the correct hosts as advertised by the server.
GetEndpointResponse also returns four endpoints with localhost as host in the EndpointUrl
However, the very same setup works fine when browsing the server with UaExpert. I cannot see any difference between the whiseshark log made in the MAtlab Session and in the UaExpert Sesion. (No security) as shown below.
Matlab session log for Endpoint[0]
UaExpert session log for Endpoint[0]
Any hint wil be very much appreciated.
Jose, the server endpoint URL returned by "GetEndPointsResponse" contains "localhost" as the hostname. This is different from the hostname "u114193" in the "FindServerResponse".
  • Do you get a hostname replacement warning when using uaExpert to connect? If so, then uaExpert might be replacing "localhost" with "u114193" as hostname in the EndpointURL when you confirm the action in order to make succesfull connection.
  • Could you also try adding a localhost - IPaddress mapping in the etc/hosts file in addition to the mapping for u114193?
Thnak you for your replay.
UaExpert does not show any warning.
Setting etc/hosts does not help either.
I have also tweacked (sorry for this) the fileds definition for the opcuaserverinfo.Endpoints().EndpointsURL and the opcuaaclientinfo.Endpoints().EndpointsURL so that they can be written at runtime, to make sure they use the URL with the host name, with no luck. For example, I could assign the orginal string to replace the localhost deffinition.
s.Endpoints(1).EndpointUrl = 'opc.tcp://u114193:62640/IntegrationObjects/ServerSimulator'
Still dooes not connect.
Prosys OPC UA Browser also works ok.
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.
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.

Connectez-vous pour commenter.

Narvik
Narvik le 24 Nov 2023
Modifié(e) : Narvik le 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 commentaire

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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Version

R2022b

Question posée :

le 10 Oct 2023

Commenté :

le 23 Mai 2024

Community Treasure Hunt

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

Start Hunting!

Translated by