From 16bedc50fa271d8f383e8f61c572704bfc6f9f17 Mon Sep 17 00:00:00 2001 From: Lehel Date: Fri, 7 Jan 2022 16:09:41 +0100 Subject: [PATCH] NIFI-9506: Fixed Nifi reconnects with websocket server each second This closes #5645. Signed-off-by: Peter Turcsanyi --- .../websocket/AbstractWebSocketGatewayProcessor.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nifi-nar-bundles/nifi-websocket-bundle/nifi-websocket-processors/src/main/java/org/apache/nifi/processors/websocket/AbstractWebSocketGatewayProcessor.java b/nifi-nar-bundles/nifi-websocket-bundle/nifi-websocket-processors/src/main/java/org/apache/nifi/processors/websocket/AbstractWebSocketGatewayProcessor.java index c516464eb2..d3ee282875 100644 --- a/nifi-nar-bundles/nifi-websocket-bundle/nifi-websocket-processors/src/main/java/org/apache/nifi/processors/websocket/AbstractWebSocketGatewayProcessor.java +++ b/nifi-nar-bundles/nifi-websocket-bundle/nifi-websocket-processors/src/main/java/org/apache/nifi/processors/websocket/AbstractWebSocketGatewayProcessor.java @@ -128,9 +128,8 @@ public abstract class AbstractWebSocketGatewayProcessor extends AbstractSessionF if (context.hasIncomingConnection()) { final ProcessSession session = processSessionFactory.createSession(); final FlowFile flowFile = session.get(); - final Map attributes = flowFile.getAttributes(); try { - webSocketClientService.connect(endpointId, attributes); + webSocketClientService.connect(endpointId, flowFile.getAttributes()); } finally { session.remove(flowFile); session.commitAsync(); @@ -195,7 +194,7 @@ public abstract class AbstractWebSocketGatewayProcessor extends AbstractSessionF throw new ProcessException("Failed to register processor to WebSocket service due to: " + e, e); } - } else { + } else if (context.hasIncomingConnection()) { try { onWebSocketServiceReady(webSocketService, context); } catch (IOException e) {