Skip to content

Commit

Permalink
Fix failures which cause .NET reference server and prosys simulation …
Browse files Browse the repository at this point in the history
…server fail.

Signed-off-by: Łukasz Dywicki <[email protected]>
  • Loading branch information
splatch committed Dec 18, 2023
1 parent 0b1bc6b commit d67eec1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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("(.(?<transportCode>tcp))?://" +
public static final Pattern INET_ADDRESS_PATTERN = Pattern.compile("(.(?<transportCode>tcp|https?))?://" +
"(?<transportHost>[\\w.-]+)(:" +
"(?<transportPort>\\d*))?");

Expand Down Expand Up @@ -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"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExtensionObjectDefinition> 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);
Expand Down

0 comments on commit d67eec1

Please sign in to comment.