{"id":19494702,"url":"https://github.com/ceejbot/keep-alive-agent","last_synced_at":"2025-04-25T21:31:57.561Z","repository":{"id":5796427,"uuid":"7010884","full_name":"ceejbot/keep-alive-agent","owner":"ceejbot","description":"a keep-alive agent for node http \u0026 https with a really snappy name","archived":false,"fork":false,"pushed_at":"2017-05-02T18:11:19.000Z","size":14,"stargazers_count":33,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-18T20:25:32.821Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceejbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-05T02:48:16.000Z","updated_at":"2022-11-18T20:29:15.000Z","dependencies_parsed_at":"2022-09-20T05:28:08.889Z","dependency_job_id":null,"html_url":"https://github.com/ceejbot/keep-alive-agent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fkeep-alive-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fkeep-alive-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fkeep-alive-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fkeep-alive-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceejbot","download_url":"https://codeload.github.com/ceejbot/keep-alive-agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250349044,"owners_count":21415913,"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-10T21:32:11.597Z","updated_at":"2025-04-25T21:31:57.256Z","avatar_url":"https://github.com/ceejbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# keep-alive-agent\n\n[![Build Status](https://travis-ci.org/ceejbot/keep-alive-agent.png)](https://travis-ci.org/ceejbot/keep-alive-agent)\n\nkeep-alive-agent is an HTTP connection pool [agent](http://nodejs.org/api/http.html#http_class_http_agent) for node.js that re-uses sockets. It is simpler than some agents that also solve this problem because it does not attempt to replace the Agent provided by node. If you want to re-use connections, use this agent. If you want the default node behavior, use the default global agent.\n\n## Update\n\nThe [node.js bug](https://github.com/joyent/node/issues/4373) this module was written to work around was fixed in node 0.8.20. It is still handy as a general keep-alive agent, however.\n\n## Usage\n\n__new KeepAliveAgent(\u003ci\u003eoptions-hash\u003c/i\u003e)__\n\nCreate an instance of the agent, passing the options hash through to the node Agent constructor. These options are in turn passed along to `createConnection()`. The KeepAliveAgent constructor does not use the options itself. The option you are most likely to change is `maxSockets`, which defaults to 5.\n\nTo use the agent instance, set it in the `agent` field of the options passed to `http.request()` or `http.get()`. See the [http.request() documentation](http://nodejs.org/api/http.html#http_http_request_options_callback) for details.\n\nExample:\n\n```javascript\nvar http = require('http'),\n    KeepAliveAgent = require('keep-alive-agent');\n\nvar getOptions = {\n    hostname: 'twitter.com',\n    port: 80,\n    path: '/dshaw',\n    agent: new KeepAliveAgent(),\n};\nhttp.get(getOptions, function(response)\n{\n\tresponse.pipe(process.stdout);\n});\n```\n\n__new KeepAliveAgent.Secure(\u003ci\u003eoptions-hash\u003c/i\u003e)__\n\nA keep-alive agent that creates tls sockets. Use it the same way you use the http agent.\n\nExample:\n\n```javascript\nvar https = require('https'),\n    KeepAliveAgent = require('keep-alive-agent');\n\nvar getOptions = {\n    hostname: 'www.duckduckgo.com',\n    port: 443,\n    path: '/?q=unicorns',\n    agent: new KeepAliveAgent.Secure(),\n};\nhttps.get(getOptions, function(response)\n{\n\tresponse.pipe(process.stdout);\n});\n```\n\n## See Also\n\nFor other implementations, see [agentkeepalive](https://github.com/TBEDP/agentkeepalive) and the [request](https://github.com/mikeal/request) module's [ForeverAgent](https://github.com/mikeal/request/blob/master/forever.js).\n\n## Licence\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fkeep-alive-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceejbot%2Fkeep-alive-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fkeep-alive-agent/lists"}