I tried to set a timeout to all the requests I do in the server, like
this:
var req = http.request(options, function(res) {
//blahblah
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.setTimeout(SOCKET_TIMEOUT);
Where SOCKET_TIMEOUT corresponds to 1200000, which is 20 minutes. I
have the req.on('error', ...) everywhere in my server and looking at
the logs, I see a lot of "problem with request: connect ETIMEDOUT".
This means it falls into that case, even though 20 minutes haven't
passed yet. I'm sure it's not a problem of the socket server because
on the server side, on every request I have something like this:
app.post('/some/:path', function(req, res){
req.connection.setTimeout(SOCKET_TIMEOUT);
//do the rest
});
So I actually don't know what's going on here. Do you think there is
something more I'm forgetting to do? Or am I doing something wrong
here?
Thanks
On Mar 30, 9:47 pm, Ben Noordhuis <[email protected]> wrote:
> On Fri, Mar 30, 2012 at 17:33,Masiar<[email protected]> wrote:
> > Thanks! Now I know what to do. I checked the connections to the
> > clients and already seem to be keep-alive (from liveHTTPHeaders)
> > without me setting it manually on both sides, can you tell me how to
> > set a timeout for incoming requests? Thanks.
>
> HTTP keep-alive is not related to TCP keep-alive. HTTP keep-alive
> tells the server to keep the connection open after the request is
> finished. TCP keep-alive is a mechanism to keep TCP connections open
> (efficiently) for long periods of time.
>
> req.connection.setTimeout() lets you set the timeout in your server.
--
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