{"id":21744050,"url":"https://github.com/telefonica/node-http-pooling-agent","last_synced_at":"2025-04-13T05:07:28.830Z","repository":{"id":34137783,"uuid":"37972255","full_name":"Telefonica/node-http-pooling-agent","owner":"Telefonica","description":"HTTP agent with smart socket pool","archived":false,"fork":false,"pushed_at":"2015-06-25T16:04:21.000Z","size":128,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-13T05:07:23.782Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Telefonica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-24T08:28:15.000Z","updated_at":"2021-10-22T09:47:46.000Z","dependencies_parsed_at":"2022-08-18T00:35:47.241Z","dependency_job_id":null,"html_url":"https://github.com/Telefonica/node-http-pooling-agent","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-http-pooling-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-http-pooling-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-http-pooling-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Fnode-http-pooling-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Telefonica","download_url":"https://codeload.github.com/Telefonica/node-http-pooling-agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T07:09:50.675Z","updated_at":"2025-04-13T05:07:28.811Z","avatar_url":"https://github.com/Telefonica.png","language":"JavaScript","readme":"# http-pooling-agent\n\nHTTP agent with smart socket pool.\n\n[![npm version](https://badge.fury.io/js/http-pooling-agent.svg)](http://badge.fury.io/js/http-pooling-agent)\n[![Build Status](https://travis-ci.org/telefonica/node-http-pooling-agent.svg)](https://travis-ci.org/telefonica/node-http-pooling-agent)\n\nThe HTTP agent is based on original [node HTTP agent](https://github.com/joyent/node/blob/f3189ace6b5e31a874df421ac2f74da0e77cb14d/lib/_http_agent.js) with some modifications in order to:\n* Do not close sockets if there is no pending HTTP request. Default HTTP agent only reuses an open socket if there is a request already waiting for delivery. However, in stress situations, it is probable to close a socket that could be reused for a new request that is about to reach, degrading the performance and exhausting the available sockets to open new connections.\n* Close sockets after a configurable period of inactivity to save resources. It uses the `freeSocketsTimeout` option to set up this inactivity period (in milliseconds).\n\nUnlike other available HTTP agents, sockets are not opened forever. After an inactivity period, they are closed to save resources.\n\n## Installation\n\n```bash\nnpm install http-pooling-agent\n```\n\n## Basic usage\n\n### HTTP usage\n\n```js\nvar http = require('http'),\n    httpAgent = require('http-pooling-agent');\n\nvar agent = new httpAgent.Agent({\n  freeSocketsTimeout: 10000\n});\n\nvar options = {\n  host: 'localhost',\n  port: 3000,\n  path: '/',\n  method: 'GET',\n  agent: agent\n};\nvar req = http.request(options, function (res) {\n});\nreq.end();\n```\n\n### HTTPS usage\n\n```js\nvar https = require('https'),\n    httpAgent = require('http-pooling-agent');\n\nvar agent = new httpAgent.SSL.Agent({\n  keepAliveMsecs: 5000\n});\n\nvar options = {\n  host: 'localhost',\n  port: 8443,\n  path: '/',\n  method: 'GET',\n  agent: agent\n};\nvar req = https.request(options, function (res) {\n});\nreq.end();\n```\n\n## Configuration\n\nThe agent is configured with a set of options:\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n| keepAlive | Boolean | true | Keep sockets around in a pool to be used by other requests in the future |\n| keepAliveMsecs | Integer | 30000 | When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Only relevant if keepAlive is set to true. |\n| maxSockets | Number | Infinity | Maximum number of sockets to allow per host. |\n| maxFreeSockets | Number | Infinity | Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. |\n| freeSocketsTimeout | Integer | 45000 | Maximum inactivity period (in milliseconds) to keep open an idle socket. |\n\n**NOTE**: These options are the same options than the [default agent](https://nodejs.org/api/http.html#http_new_agent_options) with two differences:\n* Default values are different.\n* The option `freeSocketsTimeout` does not exist in the default agent.\n\n## License\n\nCopyright 2015 [Telefónica Investigación y Desarrollo, S.A.U](http://www.tid.es)\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelefonica%2Fnode-http-pooling-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelefonica%2Fnode-http-pooling-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelefonica%2Fnode-http-pooling-agent/lists"}