From 1fec06299d89b6823ee15664b139c7e15c278bc3 Mon Sep 17 00:00:00 2001 From: gbayasgalan Date: Fri, 6 Dec 2024 12:26:17 +0100 Subject: [PATCH] FIX: el rpc request --- launcher/src/backend/SSHService.js | 32 ++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/launcher/src/backend/SSHService.js b/launcher/src/backend/SSHService.js index 1ea148a77..6bb92a27a 100755 --- a/launcher/src/backend/SSHService.js +++ b/launcher/src/backend/SSHService.js @@ -310,14 +310,34 @@ export class SSHService { log.error("Forwarding error: ", err); return; } + // Track data size for el rpc + connection.on("data", (data) => { + stream.write(data); + this.handleReceivedData(data.length, forwardOptions.srcPort); + }); - // Pipe the connection to the stream and vice versa - connection.pipe(stream).pipe(connection); + connection.on("end", () => { + stream.end(); + }); + stream.on("end", () => { + connection.end(); + }); - // Listen for data on the stream - stream.on("data", (data) => { - // Call the handleReceivedData method to handle the received data - this.handleReceivedData(data.length, forwardOptions.srcPort); + connection.on("error", (error) => { + log.error("Connection error: ", error); + stream.end(); + }); + + stream.on("error", (error) => { + log.error("Stream error: ", error); + connection.end(); + }); + + connection.on("close", () => { + stream.destroy(); + }); + stream.on("close", () => { + connection.destroy(); }); } );