-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Description
- Version: v6.2.2
- Platform: Windows 7 64-bit
- 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.