0

I use node.js(restify) and request module(https://www.npmjs.com/package/request). My node server is proxy and request to other server. I want to set socket timeout and read timeout each. like clientSocket.connect / clientSocket.setSoTimeOut in java. But request module document give "timeout" only.

Can i set socket timeout and read timeout another value?

1 Answers1

0

It doesn't appear that you can. From the documentation:

timeout - Integer containing the number of milliseconds to wait for a server
to send response headers (and start the response body) before aborting the
request. Note that if the underlying TCP connection cannot be established, the
OS-wide TCP connection timeout will overrule the timeout option (the default
in Linux can be anywhere from 20-120 seconds).

So for the actual connection timeout you're relying on the OS. If you have that under your control you could change that if need be.

If you want the control you're looking for you could always use the clients that come with restify. For instance, the documentation for the JSON client shows these options:

connectTimeout  Number  Amount of time to wait for a socket
requestTimeout  Number  Amount of time to wait for the request to finish
HeadCode
  • 2,770
  • 1
  • 14
  • 26