Discovers available OPC-UA servers on the network and returns information about them, using the specified discovery host, and specifying the capabilities that the servers must have.
            Discovers available OPC-UA servers on the network.
This method discovers available OPC-UA servers on the network and returns information about them. It uses the so-called Local Discovery Server with Multicast Extensions (LDS-NE). You can influence how the discovery works using the properties in OpcLabs.EasyOpc.UA.EasyUAClientCore.SharedParameters.
Invokes the FindServersOnNetwork service.
See also in Knowledge Base: Technical note-OPC UA Discovery in QuickOPC.
            
            Syntax
            
        
            Parameters
- serverCapabilityFilter
- List of Server capability filters. Only records with all the specified server capabilities are returned.
The value of this parameter can be null(Nothingin Visual Basic).
 
- discoveryHost
- The name of the machine that runs the discovery server that will be used for discovery task.
The value of this parameter can be null(Nothingin Visual Basic).
 
Return Value
Returns a collection of application elements (servers, 
OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement).
This method never returns null (Nothing in Visual Basic).
The individual elements of the returned value are never null (Nothing in Visual Basic).
 
            Exceptions
| Exception | Description | 
|---|
| System.ArgumentNullException | 
            A nullreference (Nothingin Visual Basic) is passed to a method that does not accept it as a valid argument. 
            This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception. | 
| OpcLabs.EasyOpc.UA.OperationModel.UAException | 
            The OPC UA operation has failed. This operation exception in uniformly used to allow 
            common handling of various kinds of errors. The System.Exception.InnerException always contains
            information about the actual error cause. 
            This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately. | 
Example
COM
             
    
	
		REM This example shows how to obtain information about OPC UA servers available on the network.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.
Public Sub DiscoverNetworkServers_Main_Command_Click()
    OutputText = ""
    ' Instantiate the client object
    Dim Client As New EasyUAClient
    ' Obtain collection of application elements
    On Error Resume Next
    Dim DiscoveryElementCollection As UADiscoveryElementCollection
    Set DiscoveryElementCollection = Client.DiscoverNetworkServers(Nothing, "opcua.demo-this.com")
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0
    
    ' Display results
    Dim DiscoveryElement As UADiscoveryElement: For Each DiscoveryElement In DiscoveryElementCollection
        OutputText = OutputText & vbCrLf
        OutputText = OutputText & "Server name: " & DiscoveryElement.ServerName & vbCrLf
        OutputText = OutputText & "Discovery URI string: " & DiscoveryElement.DiscoveryUriString & vbCrLf
        OutputText = OutputText & "Server capabilities: " & DiscoveryElement.serverCapabilities.ToString & vbCrLf
    Next
End Sub
	 
	
		Rem This example shows how to obtain information about OPC UA servers available on the network.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.
Option Explicit
' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
' Obtain collection of application elements
On Error Resume Next
Dim DiscoveryElementCollection: Set DiscoveryElementCollection = _
    Client.DiscoverNetworkServers(Nothing, "opcua.demo-this.com")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0
' Display results
Dim DiscoveryElement: For Each DiscoveryElement In DiscoveryElementCollection
    WScript.Echo
    WScript.Echo "Server name: " & DiscoveryElement.ServerName
    WScript.Echo "Discovery URI string: " & DiscoveryElement.DiscoveryUriString
    Dim s: s = ""
    Dim serverCapability: For Each serverCapability In DiscoveryElement.ServerCapabilities
        s = s & serverCapability & " "
    Next
    WScript.Echo "Server capabilities: " & s
Next
	 
	
 
Requirements
 
Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows
            
            See Also