C++ Based OPC UA Client/Server/PubSub SDK
Starting points for users of the PubSub functionality

For the integration of PubSub into an OPC UA Server application, the application must load the PubSubManager as part of the Serer SDK start-up code. The necessary sample code can be found in the C++ SDK Demo Server in the file servermain.cpp.

The sample code shows how to create the PubSubManager and how to add it to the server object.

// Create and initialize server object
OpcServer* pServer = new OpcServer;
pServer->setServerConfig(sConfigFileName, szAppPath);
// We need client functionality for PubSub security key exchange
// Create client library and set on server
pServer->setUaClientLibrary(new UaClientSdk::UaSdkClientLibrary);
// Create PubSub module and set on server
pServer->setPubSubServerLibrary(new PubSubManager);
// Start OPC UA Server with PubSub
ret = pServer->start();
if ( ret == 0 )
Main OPC Server object.
Definition: opcserver.h:43
Management class for server SDK OPC UA publish subscriber module.
Definition: pubsubmanager.h:58
UaClient library implementation for the C++ SDK library interface.
Definition: uaclientsdk.h:129
int setServerConfig(const UaString &configurationFile, const UaString &sApplicationPath)
Sets the server configuration by passing the path of the configuration file.
Definition: uacoreserverapplication.cpp:261
int start()
Starts the OPC server Initializes and starts up all NodeManagers and SDK modules.
Definition: uacoreserverapplication.cpp:602

The PubSubManager stores the PubSub configuration as file. The file location and other settings like limits for PubSub configuration elements are configured through settings in the ServerConfig. The demo server uses a XML configuration file for these settings. The detailed description of the settings is provided in PubSub Module Configuration in XML

The PubSub communication configuration can be done on-line with an external PubSub configuration tool acting as OPC UA Client, or off-line by creating the PubSub configuration binary file in the UA binary format defined by the OPC UA specification. The creation of both an on-line and an off-line configuration is described in the Getting Started. See PubSub Configuration Options for a complete list of configuration options.

The access to the on-line PubSub configuration requires user authentication and authorization. The PublishSubscribe object with the current configuration and methods to modify the configuration can be found below the Server object. The object is visible for users with the Roles Anonymous and AuthenticatedUser. Changes to the configuration require a user with the role ConfigureAdmin. Sample code for user authentication can be found in the C++ SDK Demo Server in the part User Authentication

The UA PubSub Base Library provides a class library for creating and managing a PubSub configuration. The library is able to load and store the standard OPC UA PubSubConfiguration binary file.

The example PubSubImporter, used in Getting Started, provides an example for the use of the UA PubSub Base Library. The example imports a PubSub configuration from a simplified INI file and creates the PubSub configuration using the UA PubSub Base Library.

The following pages provide further information on the PubSub functionality in the SDK: