diff --git a/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java b/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java index 6e9444f29..18948a69d 100644 --- a/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java +++ b/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java @@ -178,8 +178,8 @@ public class OpcUaClient { * Create an {@link OpcUaClient} configured with {@code config}. * * @param config the {@link OpcUaClientConfig}. - * @return an {@link OpcUaClient} configured with {@code config}. - * @throws UaException if the client could not be created (e.g. transport/encoding not supported). + * @return a new {@link OpcUaClient} configured with {@code config}. + * @throws UaException if the client could not be created. */ public static OpcUaClient create(OpcUaClientConfig config) throws UaException { OpcTcpClientTransportConfig transportConfig = OpcTcpClientTransportConfig.newBuilder().build(); @@ -188,6 +188,27 @@ public static OpcUaClient create(OpcUaClientConfig config) throws UaException { return new OpcUaClient(config, transport); } + /** + * Create an {@link OpcUaClient} configured with {@code config}. + * + * @param config the {@link OpcUaClientConfig}. + * @param configureTransport a Consumer that receives an {@link + * OpcTcpClientTransportConfigBuilder} that can be used to configure the transport. + * @return a new {@link OpcUaClient} configured with {@code config}. + * @throws UaException if the client could not be created. + */ + public static OpcUaClient create( + OpcUaClientConfig config, Consumer configureTransport) + throws UaException { + + var transportConfigBuilder = OpcTcpClientTransportConfig.newBuilder(); + configureTransport.accept(transportConfigBuilder); + + OpcTcpClientTransportConfig transportConfig = transportConfigBuilder.build(); + + return new OpcUaClient(config, new OpcTcpClientTransport(transportConfig)); + } + /** * Select the first endpoint with no security that allows anonymous connections and create an * {@link OpcUaClient} with the default configuration.