Does nodejs http client has a limit concurrency connection

1,209 views
Skip to first unread message

jason.桂林

unread,
Mar 7, 2011, 12:54:38 AM3/7/11
to nod...@googlegroups.com

hey, guys

I have question about http client, when I request too much resources of one site, some request will occurs NS_ERROR_CONNECTION_REFUSED error. How to fix?

http.request(options, callback)


--
Best regards,

Jason Green
桂林


Isaac Schlueter

unread,
Mar 7, 2011, 1:10:32 AM3/7/11
to nod...@googlegroups.com
http.request(options, callback)
.on("error", function (er) { ... handle the error ... })

How to keep hosts from refusing connections when you're flooding them?
Can't help you there, I'm afraid.

--i

> --
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en.
>

Mingli Yuan

unread,
Mar 7, 2011, 1:12:52 AM3/7/11
to nod...@googlegroups.com, jason.桂林
Hi, Json.

I think you should implement it by yourself. Just search "throttling" by google will give you some hint.

For example, below link in stackoverflow:
http://stackoverflow.com/questions/1407113/throttling-method-calls-to-m-requests-in-n-seconds

This links gives us some data structure to implements a throttling mechanism.

Regards,
Mingli

Mikeal Rogers

unread,
Mar 7, 2011, 1:18:52 AM3/7/11
to nod...@googlegroups.com
node's http client does internal pooling of requests, the default maxSockets per host is 5.

you can overwrite this by creating your own agent or just setting agent to false.

http.request({host:'www.google.com', agent:false, .....)

when you go over 5 requests it will just hold them back until there is a free socket, it would only error if there was a timeout. the error you are seeing is probably because you are either exhausting the remote host connection limit which you can fix by lowering maxSockets or it's because you simply made too many connections per minute and you're getting throttled.

jason.桂林

unread,
Mar 7, 2011, 2:14:57 AM3/7/11
to nod...@googlegroups.com
thanks all your guys

2011/3/7 Mikeal Rogers <mikeal...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
Reply all
Reply to author
Forward
0 new messages