a keep-alive agent for http and https
keep-alive-agent is an HTTP connection pool 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.
Create 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.
To use the agent instance, set it in the
agent field of the options passed to
http.get(). See the http.request() documentation for details.
A keep-alive agent that creates tls sockets. Use it the same way you use the http agent.
var http =KeepAliveAgent = ;var getOptions =hostname: 'twitter.com'port: 80path: '/dshaw'agent:;http;
To re-use secure connections, use the Secure keep-alive agent:
var https =KeepAliveAgent = ;var getOptions =hostname: 'www.duckduckgo.com'port: 443path: '/?q=unicorns'agent:;https;