I was wondering what happens when maxSockets
is reached?
If I'm using a service that allows me to create a custom http.Agent
and I specify maxSockets
to 1. What happens when I try to issues multiple concurrent requests?
Will each request beyond the initial block until the initial is plete?? Then the socket would bee available to the next request? and all others block? I would certainly assume so, but was not able to find anything in the docs specifically, and am brand new to socket programming.
I was wondering what happens when maxSockets
is reached?
If I'm using a service that allows me to create a custom http.Agent
and I specify maxSockets
to 1. What happens when I try to issues multiple concurrent requests?
Will each request beyond the initial block until the initial is plete?? Then the socket would bee available to the next request? and all others block? I would certainly assume so, but was not able to find anything in the docs specifically, and am brand new to socket programming.
Share Improve this question asked Nov 19, 2015 at 15:16 dm03514dm03514 56k18 gold badges117 silver badges147 bronze badges1 Answer
Reset to default 8After maxSockets are in use, additional requests get queued until an active request pletes and a socket is freed up to be used, at which point a pending request from the queue would be sent on the newly-freed socket.
Note this is technically queueing not blocking - the CPU and event loop continue to do useful work during this process.
Note also there is a maxSockets and queue on a per-origin ("host:port") basis (similar to browsers).
Also note that the default maxSockets is Infinity.