Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http, net: socket "inactivity" timeout #3319

Closed
silverwind opened this issue Oct 11, 2015 · 7 comments · May be fixed by B020239/node#1
Closed

http, net: socket "inactivity" timeout #3319

silverwind opened this issue Oct 11, 2015 · 7 comments · May be fixed by B020239/node#1
Labels
doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. net Issues and PRs related to the net subsystem.

Comments

@silverwind
Copy link
Contributor

d258fb0 added this explanation to server.timeout:

The number of milliseconds of inactivity before a socket is presumed to have timed out.

I noticed that long running (but active) requests like file uploads were cancelled after the timeout had passed and I'm almost certain that there is no actual code that checks for activity on a socket.

Should we update the docs so they state that the socket timeout is actually unconditional? Alternatively, we could possibly reset the timeout on activity, but that will have a perf impact.

@silverwind silverwind added http Issues or PRs related to the http subsystem. doc Issues and PRs related to the documentations. net Issues and PRs related to the net subsystem. labels Oct 11, 2015
@brendanashworth
Copy link
Contributor

Please correct me if I'm wrong, but doesn't net use _unrefTimer to handle timeouts? And http just inherits that?

@julien-f
Copy link
Contributor

I have the same issue, a long running post request is killed by the timeout even though there is some activity.

@tflanagan
Copy link
Contributor

This sounds like a code bug rather than a doc bug.

Edit: Is this the default 120 seconds found at /lib/_http_server.js:243? I think I've unknowingly run into this issue before. I wrote a small helper script that bugged out on a couple files the first time, but, with no change, worked again the second time. Couple months ago, haven't used it since tho

@silverwind
Copy link
Contributor Author

@tflanagan yes, 120 seconds defined here. You can also do it on a per-request basis with res.setTimeout, which is useful if you only want POSTs to have a longer timeout, for example.

I'm not sure if an implementation that keeps sockets alive on activity isn't a DoS risk, so I marked this a docs issue.

@tflanagan
Copy link
Contributor

It certainly is a DoS risk. However, an unconditional timeout is one extreme, whereas the subsequent documentation on setting it to 0 is the other extreme.

Perhaps a new activityTimeout setting is in order? In parallel to timeout.

@vvo
Copy link

vvo commented Dec 9, 2015

Hi, I was also surprised by this. I was used to a socket inactivity timeout since long time with nodejs request.setTimeout but it is no more, it's now a global timeout.

Should we fix the code or the docs so?

@silverwind
Copy link
Contributor Author

Closing in favor of #5899 which has a bit more detail and a example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants