node 0.3.6 http.request setTimeout?

1,076 views
Skip to first unread message

erdem

unread,
Jan 25, 2011, 11:33:53 AM1/25/11
to nodejs
I was setting the timeout value for a http request as such:
var client = http.createClient(80, 'www.google.com');
client.connection.setTimeout(5000);

As I see, there is a new Http API on 0.3.6 and there is no setTimeout
method for streams.

How can I set the timeout value for a http request?

Thanks,
erdem

mscdex

unread,
Jan 25, 2011, 2:00:00 PM1/25/11
to nodejs
setTimeout() still exists the way it did previously for sockets:
https://github.com/ry/node/blob/master/lib/net.js#L693

Liam

unread,
Jan 25, 2011, 2:34:49 PM1/25/11
to nodejs
Which means reaching into the ClientRequest for the underlying
socket... Seems like http.request options should include a 'timeout'
member.

Maybe we should forward to nodejs-dev?

Ryan Dahl

unread,
Jan 25, 2011, 3:51:59 PM1/25/11
to nod...@googlegroups.com

This will be fixed in v0.3.7 - due out today or tomorrow.

erdem

unread,
Jan 25, 2011, 4:33:09 PM1/25/11
to nod...@googlegroups.com
Thanks ryan.

erdem

unread,
Jan 28, 2011, 3:43:02 AM1/28/11
to nod...@googlegroups.com
Hello ryan,

Today I've install v0.3.7 but still I can't figure out how to set timeout value for httpClientRequest.

Do you have any suggestions?

Thanks,
erdem

Matt Freeman

unread,
Jan 28, 2011, 5:49:15 AM1/28/11
to nod...@googlegroups.com
Something similar for non-responding hosts ECONNRESET etc.. would be
good instead of reaching in to get the socket. I am using 0.2.5 though
so this may have been resolved since

> --
> 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.
>

Jimmi

unread,
Jan 28, 2011, 9:31:54 AM1/28/11
to nodejs
Hi

I just added setTimeout() for http request https://github.com/kembaren/node

Here is how you use it:

var http = require('http');
http.setTimeout(1000);

Thanks
jimmi

Ryan Dahl

unread,
Jan 28, 2011, 11:47:55 AM1/28/11
to nod...@googlegroups.com


req.connection.setTimeout

Reply all
Reply to author
Forward
0 new messages