Main Content


Connect OPC UA client to server



connect(UaClient) connects the OPC UA client UaClient to its referenced server using anonymous user authentication.

connect(UaClient, UserName, Password) connects the OPC UA Client UaClient to its server using username and password authentication. The UserName and Password arguments must be provided, although the Password field can be empty.

connect(UaClient,PublicKeyFilename,PrivateKeyFileName,PrivateKeyPassword) connects the OPC UA Client UaClient to its server using the User Certificate stored in the public and private key files referenced by PublicKeyFilename and PrivateKeyFilename. PrivateKeyPassword is the password used to protect the Private Key File. Private Key Files for OPC must be password protected. The files must be in .DER format.

When the client successfully connects to the server, the client object Status property is set to 'Connected', the first level of the server namespace is retrieved, and various essential properties of the client are read from the server.

If UaClient is a vector of clients, and some but not all clients can connect, a warning is issued. If no clients can connect, an error is generated. You can only connect a vector of clients using the same username and password, or the same certificate parameters. If you need to use different usernames and passwords for different servers, call connect on each of the clients individually.


collapse all

Locate an OPC UA server and connect a client to it.

s = opcuaserverinfo('localhost');
UaClient = opcua(s(1));

Check the connection status.


Input Arguments

collapse all

OPC UA client, specified as an OPC UA client object or array of objects.

Example: opcua()

Version History

Introduced in R2015b

See Also