Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(transport): enable keep-alives and limit number of sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt authored and kamilogorek committed Sep 26, 2017
1 parent 868e8e0 commit 9dbfdd5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/transports.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ var timeoutReq = require('timed-out');
var http = require('http');
var https = require('https');

var agentOptions = { keepalive: true, maxSockets: 100 };
var httpAgent = new http.Agent(agentOptions);
var httpsAgent = new https.Agent(agentOptions);

function Transport() {}
util.inherits(Transport, events.EventEmitter);

function HTTPTransport(options) {
this.defaultPort = 80;
this.transport = http;
this.options = options || {};
this.agent = httpAgent;
}
util.inherits(HTTPTransport, Transport);
HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {
Expand All @@ -23,7 +28,8 @@ HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {
headers: headers,
method: 'POST',
port: client.dsn.port || this.defaultPort,
ca: client.ca
ca: client.ca,
agent: this.agent
};
for (var key in this.options) {
if (this.options.hasOwnProperty(key)) {
Expand Down Expand Up @@ -84,6 +90,7 @@ function HTTPSTransport(options) {
this.defaultPort = 443;
this.transport = https;
this.options = options || {};
this.agent = httpsAgent;
}
util.inherits(HTTPSTransport, HTTPTransport);

Expand Down

0 comments on commit 9dbfdd5

Please sign in to comment.