request-promise: set timeout for long requests
Asked Answered
V

0

6

I am using request-promise library and trying to set the timeout as milliseconds as per their documentation. I have few requests on the server side that take more than a minute to response, no matter what value I set for timeout, the request always times out after a minute. What is the correct way to set read timeout in request?

My request

rp({
  uri: "http://something.com/long_running_request",
  timeout: 180000
})
Vision answered 9/7, 2018 at 6:10 Comment(2)
There are two timeouts, one for the whope request (which you set) and another timeout nodejs will throw if the server does not respond early. So this is actually a server error as the server should at least answer with an empty package when the data comes in.Torey
Note that if the underlying TCP connection cannot be established, the OS-wide TCP connection timeout will overrule the timeout option from the docsTorey

© 2022 - 2024 — McMap. All rights reserved.