No connection with OPC toolbox

조회 수: 14 (최근 30일)
Chris Urban
Chris Urban 2020년 10월 21일
답변: Srijith Vijay 2023년 11월 14일
Dear Community,
unfortunately I can't connect to an OPC UA-Server with the OPC toolbox. I've tested this with the Prosys OPC UA Simulation Server and with a Node-Red OPC UA Server too. I can connect to each of these servers with another client (uaexpert). But with Matlab R2020a there are some problems:
>> uaClient = opcua('localhost', 53530)
Error using strncmpi
Not enough input arguments.
Error in (line 387)
if ~strncmpi(this(tI).Hostname, urlParts.Hostname, numel(this(tI).Hostname))
Error in opcua (line 43)
uaObj ={:});
Is here anybody who understands this error description?
Best regards

답변 (4개)

Julien PIBAROT 2021년 4월 9일
편집: Julien PIBAROT 2021년 8월 10일
Dears Chris & Alejandro,
you need to change your OPC UA server listening address on your server OPC.
i suposed that your actual OPC UA listening adress contains "localhost" and you need to put the explicit IP adress.
then you propably need to configure the setSecurityModel on matlab when you create your opc ua client.
for me it works on R2021a.

Cedric 2022년 2월 1일
편집: Cedric 2022년 2월 1일
Hello there,
I have the same problem as @Chris Urban. Always when I want to create a UAclient in Matlab R2020a I get the following error message:
Error using strncmpi
Not enough input arguments.
Error in (line 387)
if ~strncmpi(this(tI).Hostname, urlParts.Hostname, numel(this(tI).Hostname))
Error in opcua (line 43)
uaObj ={:});
Just as @Chris Urban I could also connect other OPC UA Clients with the server.
Regarding the solution of @Julien PIBAROT I am pretty sure, that I have the right server adress. My best try looked like that (I changed the IP for this example here, but I took the same that was working with the other OPC UA Clients):
uaClient = opcua('opc.tcp://XXX.XXX.XXX.XXX:4840')
I got the string 'opc.tcp://XXX.XXX.XXX.XXX:4840' that I used out of the Endpoint description of the other OPC UA Client.
When I look at the documentation of the 'opcua' function ( I see two lines which makes me suspicious:
Create a client using the Discovery URL of the server.
uaClient ='opc.tcp://localhost:53530/OPCUA/SimulationServer');
(If you are wondering about my port number: in the manual of the machine (with that I want to communicate with) the port 4840 is mentioned to be the right one to use)
As you can see my String: 'opc.tcp://XXX.XXX.XXX.XXX:4840' is missing kind of a similar ending as above: '/OPCUA/SimulationServer'. Right now I am not sure what to put in there. I expected to be able to check it out with using the serverinfo function (
serverList = opcuaserverinfo('XXX.XXX.XXX.XXX')
But all what I got was the following:
Connection Information:
Hostname: ''
Port: 4840
Endpoints: [0×0]
Security Information:
BestMessageSecurity: Unknown
BestChannelSecurity: Unknown
UserTokenTypes: {1×0 cell}
As you can see there are no Endpoints given, which I could adapt on my String.
So right now I am kind of clueless and getting into trial and error sessions. I think that the basical client server communiction works because of the usage of the other OPC UA clients. I also thought of the security settings that @Julien PIBAROT mentioned. But I would first be able to intialize them after the creation of a client. So this can not be the problem. Right now the matlab OPC Troubleshooting ( is my next try. I think of some configuration of my DCOM settings.
I would be really thankful if anybody can help me. If you need further information I will provide it and also setup this post if I get any new outcomes.
  댓글 수: 1
Chris Urban
Chris Urban 2022년 2월 1일
Hello Cedric,
I'm not sure anymore how I solved the problem. But I think I did use a VPN client and this has led to difficulties.
I didn't check the description of the function, but in my case I passed the endpoint like this:
uaClient = opcua('localhost', 4840)
But it seems there are two variants to give the endpoint.

댓글을 달려면 로그인하십시오.

Teemu Sillanpää
Teemu Sillanpää 2023년 1월 19일
Mathworks could you fix your toolbox? UA Expert is working fine, or opcua() not.
This error message like below is unacceptable to understand the error, or user requiring to debug the toolbox code.
Error using strncmpi
Not enough input arguments.
Error in (line 387)
if ~strncmpi(this(tI).Hostname, urlParts.Hostname, numel(this(tI).Hostname))
Error in opcua (line 46)
uaObj ={:});

Srijith Vijay
Srijith Vijay 2023년 11월 14일
This issue arises when the OPC UA Server includes certificates with endpoints that cannot be accessed by the client, particularly when the client connects through multiple interfaces.
You can find more info in the below MATLAB Answer:


Help CenterFile Exchange에서 Unified Architecture에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by