Skip to content

Commit 25778ae

Browse files
committedMar 22, 2025
fix: Hopefully resolved the issue that caused the S7 driver to regularly timeout and disconnect under heavy load.
fixes: #2043
1 parent 016cc36 commit 25778ae

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed
 

‎plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,15 @@ public CompletableFuture<PlcSubscriptionResponse> subscribe(PlcSubscriptionReque
476476
.unwrap(COTPPacket::getPayload)
477477
.check(p -> p.getTpduReference() == tpduId)
478478
.handle(p -> {
479+
// Finish the request-transaction.
480+
transaction.endRequest();
481+
479482
try {
480483
//future.complete(decodeEventSubscriptionRequest(tagName, p, subscriptionRequest));
481484
futures.get("DATA_").complete(p);
482485
} catch (Exception e) {
483486
logger.warn("Error sending 'write' message: '{}'", e.getMessage(), e);
484487
}
485-
// Finish the request-transaction.
486-
transaction.endRequest();
487488
}));
488489

489490
try {
@@ -555,13 +556,14 @@ public CompletableFuture<PlcUnsubscriptionResponse> unsubscribe(PlcUnsubscriptio
555556
.unwrap(COTPPacket::getPayload)
556557
.check(p -> p.getTpduReference() == tpduId)
557558
.handle(p -> {
559+
// Finish the request-transaction.
560+
transaction.endRequest();
561+
558562
try {
559563
future.complete(null);
560564
} catch (Exception e) {
561565
logger.warn("Error sending 'write' message: '{}'", e.getMessage(), e);
562566
}
563-
// Finish the request-transaction.
564-
transaction.endRequest();
565567
}));
566568

567569
return future;
@@ -1529,9 +1531,14 @@ private CompletableFuture<S7Message> sendInternal(S7Message request) {
15291531
.unwrap(COTPPacket::getPayload)
15301532
.check(p -> p.getTpduReference() == tpduId)
15311533
.handle(p -> {
1532-
future.complete(p);
15331534
// Finish the request-transaction.
15341535
transaction.endRequest();
1536+
1537+
try {
1538+
future.complete(p);
1539+
} catch (Exception e) {
1540+
logger.warn("Error sending 'write' message: '{}'", e.getMessage(), e);
1541+
}
15351542
}));
15361543

15371544
return future;

0 commit comments

Comments
 (0)
Please sign in to comment.