Page 1 of 1

Embedding an OPC-UA Client into an OPC-UA Server

Posted: 07 Oct 2011, 11:13
by JtR
I tried to embed some clients function into servers (in my node manager, in the OpcServer class and in main function), because i need server-to-server communication, but I have compiling errors like this:
\"error C2512: 'UaClientSdk::UaSession' : no appropriate default constructor available\".
I don't know if it's possible what I tried to do (now I resolved with separate applications), if not it will be very interesting.

Re:Embedding an OPC-UA Client into an OPC-UA Server

Posted: 21 Oct 2011, 08:31
by Support Team
There is no known problem or missing feature when you combine the C++ client and server SKD in one application.

We do that in the UaGateway product and also several users of the C++ SDK are doing that in their applications.

I am not sure why you want to use the client client functions in the main function and in the OpcServer class. I think your problem is comming from this side since the UaModule is used in the OpcServer class and the UaModule has files with the same name but in another directory.

There should be no problem if you encapsulate your client functionality in a seperate class.

Best Regards,
Unified Automation Support Team

Re:Embedding an OPC-UA Client into an OPC-UA Server

Posted: 21 Oct 2011, 09:14
by JtR
I need to implement server to server communication

Re:Embedding an OPC-UA Client into an OPC-UA Server

Posted: 21 Oct 2011, 11:26
by Support Team
There is no need to integrate the client into the OpcServer object or the main function for the Server to Server communication.

If you want to provide configuration and diagnostic information for the Server to Server communication, you can integrate this functionality including the Server to Server communication into a NodeManager. The NodeManager is loaded like any other NodeManager. You can then create a private data class for the NodeManager that has the Client SDK members or you are using a connection management class for the client connection. It is just important that you are not including the client SDK headers in the header file of the NodeManager that is then included for the main function. See sample code below.

If you want to have the Server to Server communication outside a NodeManager, you can do the same with a connection handling class using a private data class that has the client SDK connection.

Best Regards,
Unified Automation Support Team


nodemanagerclient.h

Code: Select all

class NodeManagerClientPrivate;
 
class NodeManagerClient: public NodeManager
{
public:
    NodeManagerClient();
    virtual ~NodeManagerClient();
 
    // NodeManager functions
 
private:
    NodeManagerClientPrivate* d;
};
nodemanagerclient.cpp

Code: Select all

#include "nodemanagerclient.h"
#include "uaclientuasession.h"
 
class NodeManagerClientPrivate
{
public:
    NodeManagerClientPrivate(){}
    virtual ~NodeManagerClientPrivate(){}
 
    UaClientSdk::UaSession* m_pSession;
    // Other members
};
 
NodeManagerClient::NodeManagerClient()
{
    d = new NodeManagerClientPrivate;
}
 
NodeManagerClient::~NodeManagerClient()
{
    delete d;
}

Re: Embedding an OPC-UA Client into an OPC-UA Server

Posted: 24 Aug 2016, 10:44
by ravipal
I have the same issue and would like to get some suggestion.

I would like to have a SDK (Server & Client) in one library and from my application choose whether i want to use Server or Client at runtime based on user's settings.

When i tried to include Server and Client files, i got the same error

error C2512: 'UaClientSdk::UaSession' : no appropriate default constructor available\".

In addition, is it possible to use Server and Client in the same target from same application? (As a gateway)