Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

agentkeepalive

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agentkeepalive - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

6

History.md
1.2.0 / 2014-09-02
==================
* allow set keepAliveTimeout = 0
* support timeout on working socket. fixed #6
1.1.0 / 2014-08-28

@@ -3,0 +9,0 @@ ==================

34

lib/_http_agent.js

@@ -61,4 +61,6 @@ // Copyright Joyent, Inc. and other Node contributors.

self.keepAlive = self.options.keepAlive || false;
// free keep-alive socket timeout. By default socket do not have a timeout.
// free keep-alive socket timeout. By default free socket do not have a timeout.
self.keepAliveTimeout = self.options.keepAliveTimeout || 0;
// working socket timeout. By default working socket do not have a timeout.
self.timeout = self.options.timeout || 0;
self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets;

@@ -106,12 +108,4 @@ self.maxFreeSockets = self.options.maxFreeSockets || 256;

if (self.keepAliveTimeout) {
if (!socket._onKeepAliveTimeout) {
socket._onKeepAliveTimeout = function () {
this.destroy();
self.emit('timeout');
};
}
debug('enable free socket timer');
socket.setTimeout(self.keepAliveTimeout, socket._onKeepAliveTimeout);
}
// set free keepalive timer
socket.setTimeout(self.keepAliveTimeout);
}

@@ -175,7 +169,4 @@ } else {

// disable keep-alive timer
if (socket._onKeepAliveTimeout) {
debug('disable free socket timer');
socket.setTimeout(0, socket._onKeepAliveTimeout);
}
// restart the default timer
socket.setTimeout(this.timeout);

@@ -242,2 +233,11 @@ // don't leak

function onTimeout() {
debug('CLIENT socket onTimeout');
s.destroy();
self.emit('timeout');
}
s.on('timeout', onTimeout);
// set the default timer
s.setTimeout(self.timeout);
function onRemove() {

@@ -252,2 +252,4 @@ // We need this function for cases like HTTP 'upgrade'

s.removeListener('agentRemove', onRemove);
// remove timer
s.setTimeout(0, onTimeout);
}

@@ -254,0 +256,0 @@ s.on('agentRemove', onRemove);

@@ -34,5 +34,12 @@ /**!

options = options || {};
options.keepAlive = options.keepAlive !== false;
// default is keep-alive and 15s free socket timeout
options.keepAlive = options.keepAlive !== false;
options.keepAliveTimeout = options.keepAliveTimeout || 15000;
if (options.keepAliveTimeout === undefined) {
options.keepAliveTimeout = 15000;
}
// default timeout is double keepalive timeout
if (options.timeout === undefined) {
options.timeout = options.keepAliveTimeout * 2;
}
OriginalAgent.call(this, options);

@@ -39,0 +46,0 @@

{
"name": "agentkeepalive",
"version": "1.1.0",
"version": "1.2.0",
"description": "Missing keepalive http.Agent",
"main": "index.js",
"scripts": {
"test": "make test"
"test": "mocha -R spec -t 5000 -r should-http test/*.test.js",
"test-cov": "node node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -t 5000 -r should-http test/*.test.js",
"test-travis": "node node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -- -t 5000 -r should-http test/*.test.js",
"jshint": "jshint .",
"autod": "autod -w --prefix '~' && npm run cnpm",
"cnpm": "npm install --registry=https://registry.npm.taobao.org",
"contributors": "contributors -f plain -o AUTHORS"
},

@@ -22,10 +28,12 @@ "repository": {

"dependencies": {
},
"devDependencies": {
"autod": "*",
"contributors": "*",
"istanbul": "*",
"autod": "*",
"mocha": "*",
"pedding": "~1.0.0",
"should": "~4.0.4",
"should-http": "*"
"should-http": "~0.0.2"
},

@@ -32,0 +40,0 @@ "engines": { "node": ">= 0.11.12" },

@@ -8,2 +8,4 @@ # agentkeepalive

[![David deps][david-image]][david-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]

@@ -20,6 +22,10 @@ [npm-image]: https://img.shields.io/npm/v/agentkeepalive.svg?style=flat

[david-url]: https://david-dm.org/node-modules/agentkeepalive
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.11-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/agentkeepalive.svg?style=flat-square
[download-url]: https://npmjs.org/package/agentkeepalive
The nodejs's missing `keep alive` `http.Agent`. Support `http` and `https`.
* `node >= 0.11.0`: use agentkeepalive@1.0.0+
* `node >= 0.11.0`: use agentkeepalive@1.2.0+
* `node < 0.11.0`: use agentkeepalive@0.2.2

@@ -42,6 +48,9 @@

Default = `1000`. Only relevant if `keepAlive` is set to `true`.
* `keepAliveTimeout`: {Number} Sets the socket to timeout
after `timeout` milliseconds of inactivity on the free socket.
Default is `30000`.
* `keepAliveTimeout`: {Number} Sets the free socket to timeout
after `keepAliveTimeout` milliseconds of inactivity on the free socket.
Default is `15000`.
Only relevant if `keepAlive` is set to `true`.
* `timeout`: {Number} Sets the working socket to timeout
after `timeout` milliseconds of inactivity on the working socket.
Default is `keepAliveTimeout * 2`.
* `maxSockets` {Number} Maximum number of sockets to allow per

@@ -60,4 +69,5 @@ host. Default = `Infinity`.

var keepaliveAgent = new Agent({
maxSockets: 10,
maxSockets: 100,
maxFreeSockets: 10,
timeout: 60000,
keepAliveTimeout: 30000 // free socket keepalive for 30 seconds

@@ -64,0 +74,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc