This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 819bdfa0cf2 NIFI-16611 Add connect timeout of 5 seconds to Load
Balancing Client Sockets (#11948)
819bdfa0cf2 is described below
commit 819bdfa0cf203e4c9e2f3a93df2029d9f2eedeee
Author: Jim Halfpenny <[email protected]>
AuthorDate: Fri Nov 20 17:57:57 2026 +0000
NIFI-16611 Add connect timeout of 5 seconds to Load Balancing Client
Sockets (#11948)
Signed-off-by: David Handermann <[email protected]>
---
.../queue/clustered/client/async/nio/NioAsyncLoadBalanceClient.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/client/async/nio/NioAsyncLoadBalanceClient.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/client/async/nio/NioAsyncLoadBalanceClient.java
index e7b8834a30f..c122138b0c1 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/client/async/nio/NioAsyncLoadBalanceClient.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/client/async/nio/NioAsyncLoadBalanceClient.java
@@ -60,6 +60,7 @@ import javax.net.ssl.SSLContext;
public class NioAsyncLoadBalanceClient implements AsyncLoadBalanceClient {
private static final Logger logger =
LoggerFactory.getLogger(NioAsyncLoadBalanceClient.class);
private static final long PENALIZATION_MILLIS =
TimeUnit.SECONDS.toMillis(1L);
+ private static final int CONNECT_TIMEOUT_MILLISECONDS = (int)
TimeUnit.SECONDS.toMillis(5L);
private final NodeIdentifier nodeIdentifier;
private final int timeoutMillis;
@@ -486,7 +487,9 @@ public class NioAsyncLoadBalanceClient implements
AsyncLoadBalanceClient {
final Socket socket = socketChannel.socket();
socket.setSoTimeout(timeoutMillis);
- socket.connect(new
InetSocketAddress(nodeIdentifier.getLoadBalanceAddress(),
nodeIdentifier.getLoadBalancePort()));
+ // Bound the connect: without a timeout, connecting to a peer that
silently drops packets (e.g. the old address of a
+ // restarted node) blocks for the OS TCP connect timeout, stalling
every other Client served by the same task thread
+ socket.connect(new
InetSocketAddress(nodeIdentifier.getLoadBalanceAddress(),
nodeIdentifier.getLoadBalancePort()), CONNECT_TIMEOUT_MILLISECONDS);
socket.setSoTimeout(timeoutMillis);
return socketChannel;