-
Notifications
You must be signed in to change notification settings - Fork 7.3k
HTTP Server Response Socket Timeout After Two Minutes Does Not Allow Catching timeout
event and respond to socket
#3460
Comments
I agree the current API is not well thought out. @isaacs Are you still planning to do a HTTP rewrite in v0.9? |
Yes, that is my goal. Let's collect up these issues so that we have a good set of requirements. |
In case you didn't notice the test (and tentative fix) are at 7a79de3 |
Let's revisit for 0.12. |
This bug is breaking code in production. Can we get a fix in sooner? |
I'm ok with fixing in 0.10 if it can be done relatively simply and without On Saturday, February 9, 2013, James Halliday wrote:
|
Suggestion: By the way, the 2 minute timeout is to stop a client that doesn't send headers from tying up a connection indefinitely. You don't get a request object until the headers have been received so that initial timeout can't go - at best, it can be made configurable. req.setTimeout() will need to disarm it, though. |
Oh, right, that makes sense. A 2-minute default is probably a good idea there. But, it could be based on a field on the server. Maybe We could also probably move things around so that |
net.Socket#setTimeout does that when you pass in msecs=0. I would suggest to stick with that. |
This adds the following to HTTP: * server.setTimeout(msecs, callback) Sets all new connections to time out after the specified time, at which point it emits 'timeout' on the server, passing the socket as an argument. In this way, timeouts can be handled in one place consistently. * req.setTimeout(), res.setTimeout() Just aliases to req.socket.setTimeout() or res.socket.setTimeout(), but without having to delve into a "buried" object. * server.timeout Number of milliseconds before incoming connections time out. (Default=1000*60*2, as before.) Furthermore, if the user sets up their own timeout listener on either the server or the socket, then the default behavior (destroying the socket) is suppressed. Fix nodejs#3460
@substack @dscape @davepacheco Check out #4912. Does that satisfy your needs? |
This adds the following to HTTP: * server.setTimeout(msecs, callback) Sets all new connections to time out after the specified time, at which point it emits 'timeout' on the server, passing the socket as an argument. In this way, timeouts can be handled in one place consistently. * req.setTimeout(), res.setTimeout() Essentially an alias to req/res.socket.setTimeout(), but without having to delve into a "buried" object. Adds a listener on the req/res object, but not on the socket. * server.timeout Number of milliseconds before incoming connections time out. (Default=1000*60*2, as before.) Furthermore, if the user sets up their own timeout listener on either the server, the request, or the response, then the default behavior (destroying the socket) is suppressed. Fix nodejs#3460
Hello, please read commit comments above: tshemsedinov/node@ae9a1a5 |
I need to increase the timeout of nodejs request according to particular request dynamically. because request can take any time according to process. suppose one iterate take around 5 min so any particular request can have n number of iterate according to client request. |
Currently node sets a two minute timeout on a
socket
by defaulthttp.js
Problem is that once the
timeout
event is fired the socket is destroyed, making it impossible for modules usinghttp
to intercept the event:However when you curl you get:
Which is not the expected behavior.
A work-around is to do:
Which works correctly, but at impossible to predict consequences as this is userland code and node-core might break this in the future:
A solution was indicated to me by @isaacs stating changing to
process.nextTick
semantics could easily solve this:http-modified.js
+@mmalecki
The text was updated successfully, but these errors were encountered: