-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Feature request: have http.request() accept socket timeout option which is passed to http.Agent and applied BEFORE connecting #7580
Labels
feature request
Issues that request new features to be added to Node.js.
http
Issues or PRs related to the http subsystem.
Comments
Fishrock123
added
http
Issues or PRs related to the http subsystem.
feature request
Issues that request new features to be added to Node.js.
labels
Jul 7, 2016
Thanks for bringing this issue to our attention. The request seems reasonable. Would you be able to open a pull request for this? Otherwise, I have added this to my backlog, but it might take some time for me to get to it. |
4 tasks
reneweb
added a commit
to reneweb/node
that referenced
this issue
Aug 31, 2016
This allows passing the socket connection timeout to http#request such that it will be set before the socket is connecting Fixes nodejs#7580
jasnell
pushed a commit
that referenced
this issue
Sep 29, 2016
This allows passing the socket connection timeout to http#request such that it will be set before the socket is connecting PR-URL: #8101 Fixes: #7580 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
geek
pushed a commit
to geek/node
that referenced
this issue
Sep 30, 2016
This allows passing the socket connection timeout to http#request such that it will be set before the socket is connecting PR-URL: nodejs#8101 Fixes: nodejs#7580 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Fishrock123
pushed a commit
that referenced
this issue
Oct 11, 2016
This allows passing the socket connection timeout to http#request such that it will be set before the socket is connecting PR-URL: #8101 Fixes: #7580 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Merged
10 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature request
Issues that request new features to be added to Node.js.
http
Issues or PRs related to the http subsystem.
For plain socket ('net' module) it is possible to set the socket connect timeout by using socket#setTimeout() before calling socket#connect(). On windows, this has effect as long as you keep the timeout below 20 seconds (which is the Windows default TCP connect timeout). E.g. setting 1 second and then connecting to a non-existing IP address will give a timeout after 1 second, but setting 25 seconds will still timeout after 20 seconds.
For the http module, there is no such option (http.request() does not take a timeout). There are no workarounds: using ClientRequest#setTimeout() or catching the socket in the on('socket') event and using socket#setTimeout both result in the timeout being set after the connect() call, so it does not function as a connect timeout.
So the request is to adjust http.request() function so that it takes a timeout option which is set on the socket before it connects. This will in turn require passing on the timeout to the http.Agent#createConnection() when requesting a connection.
The text was updated successfully, but these errors were encountered: