From f9fedbdb9868d516fa7b5b19d6a339236e9765af Mon Sep 17 00:00:00 2001 From: Ray Tung Date: Fri, 16 Sep 2022 14:17:30 +1000 Subject: [PATCH] fix(socket): TLS connection correctly times out Signed-off-by: Ray Tung --- src/socket.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/socket.ts b/src/socket.ts index 22884a9..64c1de9 100644 --- a/src/socket.ts +++ b/src/socket.ts @@ -400,7 +400,11 @@ export class FluentSocket extends EventEmitter { * @returns A new socket to use for the connection */ private createTlsSocket(): tls.TLSSocket { - return tls.connect({...this.tlsOptions, ...this.socketParams}); + let opts: net.NetConnectOpts = {...this.tlsOptions, ...this.socketParams}; + if (this.timeout >= 0) { + opts = {...opts, timeout: this.timeout}; + } + return tls.connect(opts); } /**