How to set maximum http client connections in Node.js

后端 未结 2 1859
栀梦
栀梦 2021-01-05 02:07

I need to increase the number of outbound http sockets usable by a module I am writing. I know it is possible to do this globally using:

//         


        
2条回答
  •  借酒劲吻你
    2021-01-05 02:30

    Your best option is to pass an Agent object to every http and https request you are making, with maxSockets configured to your liking. This will have no effect on other modules. See http://nodejs.org/docs/latest/api/http.html#http_http_request_options_callback.

    If you are using a framework yourself, rather than relying on the http module directly, it might be difficult and require some patching.

提交回复
热议问题