Back to Aurora Vision Library Lite website

You are here: Start » System » OPC UA » OPCUAClient_Connect

OPCUAClient_Connect


Header: STD.h
Namespace: avl

Establishes a connection to a OPC UA server

Syntax

void avl::OPCUAClient_Connect
(
	int inConnectionId,
	const atl::String& inEndpointURI,
	const atl::String& inUserName,
	const atl::String& inPassword,
	avl::OpcUaSecurityMode::Type inSecurityMode,
	bool inExtendedLogging
)

Parameters

Name Type Range Default Description
Input value inConnectionId int 0 - 99 0 Slot id to keep this connection in and distinguish from other connections in the application
Input value inEndpointURI const String& Server endpoint URI to connect to
Input value inUserName const String&
Input value inPassword const String&
Input value inSecurityMode OpcUaSecurityMode::Type
Input value inExtendedLogging bool False Enables additional (debug) logging of the OPC UA client activity

Description

This filter initializes a local instance of a OPC UA client and establishes a connection with a remote OPC UA server over a OPC TCP binary protocol.

The inConnectionId input can be used when working with multiple server connections at once. The value at this input determines an internal slot that the connection is held in and that other OPC UA Client filters can refer to. The connect filter can be invoked multiple times with different values on the inConnectionId input to open multiple connections. Invoking the filter more than once on the same connection id, without closing the connection first, will result in a DomainError exception. When working with a single OPC UA connection this input can be left on its default value in all OPC UA Client filters.

The mandatory inEndpointURI input specifies the full URI of the server endpoint to connect to. This URI will usually start with "opc.tcp://".

The inSecurityMode specifies the requested Security Mode configuration of the connection and can be set to one of the values: "None", "Sign", "SignAndEncrypt", as defined by the OPC UA standard. Setting this input to None (default) will result in no message encryption or signing, and no server security certificate verification. Setting this input to "Sign" or "SignAndEncrypt" requires for the local OPC UA client security to be set up first using the OPCUAClient_SetupSecurityCertificates filter (invoked before the connect filter).

The inUserName and inPassword inputs pair can be used to authenticate the client identity for the connection session, using the User Name Identity Token. When both inputs are left empty the client will attempt to use the Anonymous Identity Token. Please note that some servers might require the client security to be configured (using the OPCUAClient_SetupSecurityCertificates filter) for the User Name Identity authentication to be possible.

To diagnose and resolve server connection problems the inExtendedLogging input can be set to True. In this mode the OPC UA client will Log in the console additional diagnostic information about connection state changes or mode negotiation.

After successful invocation of the connect filter other filters from the OPC UA category can be used, with the same connection id, to read or write values from/to the OPC UA server.

To close the connection the OPCUAClient_Close filter can be used on the same connection id. All OPC UA connections will also be closed automatically when the vision application is stopped.

Errors

This filter will throw an IOError exception on any network connection problem or server connection negotiation error.

List of possible exceptions:

Error type Description
DomainError Empty server endpoint URI in OPCUAClient_Connect.
DomainError Requesting OPC UA security mode other than None without security certificates configured. Use OPCUAClient_SetupSecurityCertificates before OPCUAClient_Connect.
DomainError User credentials password provided without the user name in OPCUAClient_Connect.

See Also