Contenuto principale

opcuaserverinfo

Query host for installed OPC UA servers

    Description

    An opc.ua.ServerInfo object provides information on OPC UA servers installed on a specific host.

    Creation

    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).

    example

    Input Arguments

    expand 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

    expand all

    Server information, returned as an array of opc.ua.ServerInfo objects. Index into the array to access the individual server Properties. Use the opcua function to create an OPC UA client object directly from an opc.ua.ServerInfo object.

    Properties

    expand all

    Connection Information

    This property is read-only.

    Host name used by the OPC UA server to authenticate connections, represented as a character vector.

    Example: 'MyMachine-4u6B'

    Data Types: char

    This property is read-only.

    Port number used for TCP/IP connections to the OPC UA server, represented as a double.

    Example: 53530

    Data Types: double

    This property is read-only.

    Endpoints available for an OPC UA server, represented as an array of endpoints. Endpoints includes information about the security models supported by each endpoint and the user authentication available on that endpoint. To access the description for all the endpoints, use the syntax serverInfoObj.Endpoints.

    Example:

    >> serverInfoObj.Endpoints
    
    ans = 
    
    1×11 OPC UA EndpointDescription array:
        index  Message Security    Channel Security                User Tokens            
        -----  ----------------  ---------------------  ----------------------------------
          1    SignAndEncrypt    Aes256_Sha256_RsaPss   Anonymous | Username | Certificate
          2    Sign              Basic256               Anonymous | Username | Certificate
          3    Sign              Aes128_Sha256_RsaOaep  Anonymous | Username | Certificate
          4    Sign              Basic128Rsa15          Anonymous | Username | Certificate
          5    SignAndEncrypt    Basic256Sha256         Anonymous | Username | Certificate
          6    SignAndEncrypt    Basic128Rsa15          Anonymous | Username | Certificate
          7    None              None                   Anonymous | Username | Certificate
          8    Sign              Basic256Sha256         Anonymous | Username | Certificate
          9    SignAndEncrypt    Basic256               Anonymous | Username | Certificate
         10    Sign              Aes256_Sha256_RsaPss   Anonymous | Username | Certificate
         11    SignAndEncrypt    Aes128_Sha256_RsaOaep  Anonymous | Username | Certificate

    Security Information

    This property is read-only.

    Highest message security mode supported by the OPC UA server, represented as SignAndEncrypt or Sign or None.

    Example: SignAndEncrypt

    Data Types: enumerated

    This property is read-only.

    Highest channel security policy supported by the OPC UA server, represented as Aes256_Sha256_RsaPss, Basic256Sha256, Aes128_Sha256_RsaOaep or None.

    Example: Aes256_Sha256_RsaPss

    Data Types: enumerated

    This property is read-only.

    User authentication types supported by the OPC UA server, represented as a cell array of character vectors.

    Example:

    >> serverInfoObj.UserTokenTypes
    
    ans =
    
      1×3 cell array
    
        {'Anonymous'}    {'Username'}    {'Certificate'}

    Object Functions

    findAuthenticationFind OPC UA servers supporting specified user authentication type
    findDescriptionFind OPC UA servers containing specified description

    Examples

    collapse all

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

    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));

    Version History

    Introduced in R2015b