Skip to content

Commit bfa0b6f

Browse files
committed
test(frontend): stable telnet socket connection + error handling
1 parent ec4c3c1 commit bfa0b6f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

backend/src/features/telnet/telnet-client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ export class TelnetClient extends EventEmitter<TelnetClientEvents> {
148148

149149
this.telnetSocket.on('close', (hadErrors) => this.handleClose(hadErrors));
150150

151+
this.telnetSocket.on('error', (error: Error) => {
152+
logger.error(
153+
`[${this.socketId}] [Telnet-Client] Socket error (will close connection): ${error.message}`,
154+
{ error },
155+
);
156+
});
157+
151158
this.telnetSocket.on('do', (option) => this.handleDo(option));
152159

153160
this.telnetSocket.on('dont', (option) => this.handleDont(option));
@@ -586,5 +593,8 @@ function createTelnetConnection(
586593
});
587594
}
588595

596+
// Keep-alive helps avoid idle disconnects on intermediate proxies/LBs
597+
socket.setKeepAlive(true, 60_000);
598+
589599
return socket;
590600
}

0 commit comments

Comments
 (0)