diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java index f7c6216b715..7c6a36025fb 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java @@ -65,7 +65,7 @@ public class SecureChannel { private static final String PASSWORD_ENCRYPTION_ALGORITHM = "http://www.w3.org/2001/04/xmlenc#rsa-oaep"; public static final PascalString NULL_STRING = new PascalString(""); public static final PascalByteString NULL_BYTE_STRING = new PascalByteString(-1, null); - public static final Pattern INET_ADDRESS_PATTERN = Pattern.compile("(.(?tcp))?://" + + public static final Pattern INET_ADDRESS_PATTERN = Pattern.compile("(.(?tcp|https?))?://" + "(?[\\w.-]+)(:" + "(?\\d*))?"); @@ -526,10 +526,11 @@ private void selectEndpoint(CreateSessionResponse sessionResponse) throws PlcRun */ private boolean isEndpoint(EndpointDescription endpoint) throws PlcRuntimeException { // Split up the connection string into it's individual segments. - Matcher matcher = URI_PATTERN.matcher(endpoint.getEndpointUrl().getStringValue()); + String endpointUri = endpoint.getEndpointUrl().getStringValue(); + Matcher matcher = URI_PATTERN.matcher(endpointUri); if (!matcher.matches()) { throw new PlcRuntimeException( - "Endpoint returned from the server doesn't match the format '{protocol-code}:({transport-code})?//{transport-host}(:{transport-port})(/{transport-endpoint})'"); + "Endpoint " + endpointUri + " returned from the server doesn't match the format '{protocol-code}:({transport-code})?//{transport-host}(:{transport-port})(/{transport-endpoint})'"); } LOGGER.trace("Using Endpoint {} {} {}", matcher.group("transportHost"), matcher.group("transportPort"), matcher.group("transportEndpoint")); diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java index d7029b42d2e..074b264bab1 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java @@ -176,7 +176,9 @@ private void sendPublishRequest() { //Make a copy of the outstanding requests, so it isn't modified while we are putting the ack list together. List acks = new ArrayList<>(outstandingAcknowledgements); - int ackLength = acks.isEmpty() ? -1 : acks.size(); + // do not send -1 when requesting publish, the -1 value indicates NULL value + // which might result in corruption of subscription for some servers + int ackLength = acks.size(); outstandingAcknowledgements.removeAll(acks); PublishRequest publishRequest = new PublishRequest(requestHeader, ackLength, acks);