diff --git a/lib/connection.js b/lib/connection.js index 84382872..5d632f94 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -173,7 +173,10 @@ class Connection extends events.EventEmitter { if (!this.options.sslOptions) { this.netClient = new net.Socket({ highWaterMark: this.options.socketOptions.coalescingThreshold }); - this.netClient.connect(this.port, this.address, function connectCallback() { + this.netClient.connect({ + host: this.address, + port: parseInt(this.port, 10) + }, function connectCallback() { self.log('verbose', `Socket connected to ${self.endpointFriendlyName}`); self.bindSocketListeners(); self.startup(callback); @@ -187,7 +190,11 @@ class Connection extends events.EventEmitter { sslOptions.servername = this._serverName; } - this.netClient = tls.connect(this.port, this.address, sslOptions, function tlsConnectCallback() { + this.netClient = tls.connect({ + host: this.address, + port: parseInt(this.port, 10), + ...sslOptions + }, function tlsConnectCallback() { self.log('verbose', `Secure socket connected to ${self.endpointFriendlyName} with protocol ${self.netClient.getProtocol()}`); self.bindSocketListeners(); self.startup(callback); diff --git a/lib/streams.js b/lib/streams.js index 158cc8b7..8324eb17 100644 --- a/lib/streams.js +++ b/lib/streams.js @@ -289,7 +289,7 @@ Parser.prototype.addFrameBuffer = function (frameInfo, item) { */ Parser.prototype.getFrameBuffer = function (frameInfo, item) { frameInfo.buffers.push(item.chunk); - const result = Buffer.concat(frameInfo.buffers, frameInfo.bodyLength); + const result = Buffer.concat(frameInfo.buffers, frameInfo.bodyLength ?? frameInfo.buffers.reduce((acc, cur) => acc + cur.length, 0)); frameInfo.buffers = null; return result; };