Main Content

opcuaserverinfo

Query host for installed OPC UA servers

Description

serverInfo = opcuaserverinfo(hostname) queries the specified host for its installed OPC UA servers. hostname must be the host name or IP address of the local machine or a remote machine on the same local network.

Note

Before running opcuaserverinfo to query a host, you must set up a Local Discovery Service (LDS) on that host, as described in Install a Local Discovery Service for OPC UA Server Discovery.

serverInfo = opcuaserverinfo(discoveryUrl) queries the Discovery Service located at the URL discoveryUrl. discoveryUrl must use the opc.tcp protocol specified by the syntax "opc.tcp://hostname:port/Url". Use the discoveryUrl when your server's OPC UA Discovery Service uses a nonstandard port number (by default 4840).

serverInfo is returned as an OPC UA ServerInfo object, or an array of these objects, containing the read-only properties Description, Hostname, Port, and Endpoints. Endpoints contains a list of available endpoints for the server, as an EndpointDescription array. Endpoints includes information about the security models supported by each endpoint and the user authentication available on that endpoint.

Use the opcua function to create an OPC UA client object directly from an opc.ua.ServerInfo object.

example

Examples

collapse all

Find all available servers on the local host, and view the properties of the first.

serverInfo = opcuaserverinfo("localhost");
serverInfo(1)
OPC UA ServerInfo 'SimulationServer@tmopti01win1064':

   Connection Information:
               Hostname: 'tmopti01win1064.dhcp.mathworks.com'
                   Port: 53530
              Endpoints: [1×11 opc.ua.EndpointDescription]

   Security Information:
    BestMessageSecurity: SignAndEncrypt
    BestChannelSecurity: Aes256_Sha256_RsaPss
         UserTokenTypes: {'Anonymous'  'Username'  'Certificate'}

Create an OPC UA client for the first server found.

uaClient = opcua(serverInfo(1));

Input Arguments

collapse all

Host name or IP address, specified as a character vector or string, identifying the machine running the OPC UA servers. The host name or IP address must belong to the local machine or a remote machine on the same local network.

Example: 'localhost'

Data Types: char | string

Discovery service URL address, specified as a character vector or string in the form "opc.tcp://hostname:port/Url".

Example: 'opc.tcp://mydomain.com:4840/UADiscovery'

Data Types: char | string

Output Arguments

collapse all

Server information, returned as an array of opc.ua.ServerInfo objects. Index into the array to access the following individual server properties.

PropertyDescription
HostnameHost name used by server to authenticate connections
PortPort number used for connections to server
EndpointsAvailable endpoints for server
BestMessageSecurityHighest message security mode supported by server
BestChannelSecurityMost secure channel security policy supported by server
UserTokenTypesList of user authentication types supported by server

Version History

Introduced in R2015b