Hi Ismael,

Your best bet is to use mikael's request module which has an easy-to-use API:

https://github.com/mikeal/request

Also, have you validated that the server is working as expected using curl etc.

Richard

Sent from my iPhone

On 31 Oct 2012, at 10:39, Ismael Gorissen <[email protected]> wrote:

> Hi,
> 
> I want to execute some codes every hour, so I used a module for nodejs called 
> CRON, it works perfectly ! But now I'm facing an issue. I need to make a HTTP 
> request to a server with only an url, and this server must respond with a 
> json object (because json is define in the url). But when I'm doing this
> 
> var options = {
>         host: "domain.com",
>         path: "/path/json"
>     };
> 
>     http.request(options, function(res)
>     {
>         var data = '';
> 
>         res.setEncoding('utf8');
>         res.on('data', function(chunk)
>         {
>             data += chunk;
>         });
>         res.on('end', function()
>         {
>             console.log(data);
>         });
>     }).on('error', function(err)
>     {
>         console.log(err.message);
>     });
> 
> I always receive this message
> 
> <HTML><HEAD>
> <TITLE>Request Timeout</TITLE>
> </HEAD><BODY>
> <H1>Request Timeout</H1>
> The server timed out while waiting for the browser's request.<P>
> Reference&#32;&#35;2&#46;8a643e17&#46;1351678745&#46;0
> </BODY></HTML>
> 
> 
> any idea ? I only want to make a request, I don't need to create a server, 
> just launch the script using cronjob and launching my request each hour.
> 
> Thank you !! 
> -- 
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to