Create local discovery server for integration testing purposes

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
trumpf_jj
Jr. Member
Jr. Member
Posts: 2
Joined: 15 Nov 2023, 11:24

Create local discovery server for integration testing purposes

Post by trumpf_jj »

Dear fellow OPC developers,

I want to test my OPC-UA-Client with a OPC-UA-Server. Therefore I want to create both, the server and the client locally, and let them communicate. Unfortunetly the implementation of our client requires the server to be behind a discovery server.

Explanation:
I created an ApplicationInstanceBase instance and loaded the default configuration. When I call the Start-Method I pass the server manager to it (this - I start the application from inside the server manager).

Code: Select all

public void Start()
{
    // Create settings object and load default settings
    mAppInstanceBase = new ApplicationInstanceBase();
    mAppInstanceBase.LoadConfiguration(false, true);

    // Load license from executing assembly (the file is embedded in this project)
    ApplicationLicenseManager.AddProcessLicenses(Assembly.GetExecutingAssembly(), "License.lic");

    mAppInstanceBase.Start(this, null, this);
}
The server is accessible via UaExpert and the nodes are displayed. Unfortunetly my client-side is unable to connect:

Code: Select all

using (var tmpDiscovery = new Discovery())
{
	var server = tmpDiscovery.FindServers(mUrl);
}
because it throws a
System.MissingMethodException
with the Message
Method not found: 'UnifiedAutomation.UaBase.DiscoveryClient UnifiedAutomation.UaBase.DiscoveryClient.Create(UnifiedAutomation.UaBase.ApplicationInstanceBase, UnifiedAutomation.UaBase.EndpointConfiguration, System.Uri, System.String, UnifiedAutomation.UaBase.ApplicationThreadPool)'.
I'm confused since my server has the DiscoveryServerUrl-Property set (opc.tcp//localhost:4840) but the client is unable to connect...

I'd appreciate any type of hint or tips in general.

Thanks in advance,
Julian

trumpf_jj
Jr. Member
Jr. Member
Posts: 2
Joined: 15 Nov 2023, 11:24

Re: Create local discovery server for integration testing purposes

Post by trumpf_jj »

I found the cause of the exception. We used the UaClient-NuGet-Package with version 3.0.1 and the Server used the most current version (3.3.1).

Therefore the client probably tried to use removed methods.

I updated the client to 3.3.1 as well and everything is running fine!

This issue can therefore be closed.

Best regards,
Julian

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Create local discovery server for integration testing purposes

Post by Support Team »

Hi Julian,
glad that it works, the issue you hat was probably not related to any "discovery" server.

For all others reading this post.
To run the UA Server "behind" a discovery Server, e.g. the LDS (LocalDiscoveryServer) of the OPC Foundation, there is nothing special you must do, except "registering" your server at the LDS. This is done "automatically" when being configured in the server.config. Please note that, in order to register at the local LDS you need to trust the LDS (and vice versa). The LDS (Windows-Setup) is available at the OPC Foundation website. The LDS will always run on port 4840, hence make sure that your own server is running on different port.

For the UA Client it all works same:
1) call FindServers() on the 4840, which is the LDS
-> returns the list of registered servers and their repective discovery port
2) call GetEndpoints() on the server of desire
-> returns the available endpoints and security policies of the server being asked
3) finally connect to the Endpoint of choice.

The advantage of the LDS is just a local list of servers that are installed/registered on this one PC. Plus the use of LDSme (multicast extension) allows multiple LDS to "share" their list of servers within a network. Client can use the "FindServersOnNetwork()" to get the full picture. However, if you have only one UA Server per each PC, there is not much benefit in using the LDS at all.
Best regards
Unified Automation Support Team

Post Reply