Discovery
OpcUaDiscovery This is a static class that can be called without a session. It is used for "pre-connection detection":
Subpage Redirect
- To list all endpoints for a specific server, please refer to GetEndpoints.
- To list all servers in LDS the domain, see FindServers.
Usage Patterns
import com.darra.opcua.*;
import java.util.List;
// 1. First, getEndpoints check which combinations are supported by the server
List<EndpointDescription> endpoints =
OpcUaDiscovery.getEndpoints("opc.tcp://server:4840");
// 2. Choose a matching one (for example, + SignAndEncrypt Username)
EndpointDescription ep = endpoints.stream()
.filter(e -> e.getSecurityMode() == Enums.MessageSecurityMode.SignAndEncrypt
&& e.getUserTokens().stream().anyMatch(t ->
t.getTokenType() == Enums.UserTokenType.Username))
.findFirst()
.orElseThrow();
// 3. Use the selected endpoint to establish an actual connection
try (OpcUaSession ua = new OpcUaSession(
ep.getEndpointUrl(),
ep.getSecurityMode(),
"operator", "secret",
600_000, 10_000, 10_000,
10_000, true, true,
"client.pfx", null, // clientCertPath = PFX path; clientKeyPath = private key path (currently provided by PFX default; pass null)
null, ep.getSecurityPolicyUri())) {
ua.connect();
}