node-rest-client icon indicating copy to clipboard operation
node-rest-client copied to clipboard

requestConfig set timeout not work

Open ghost opened this issue 8 years ago • 3 comments

Please help me to review the config of requestConfig.

                  let args = {
                        headers: { 'Content-Type': 'application/json' },
                        data: {
                            
                            'data': dataUpdate
                        },
                        requestConfig: {
                            timeout: 200, // 200mili second Request timeout
                        },
                        responseConfig: {
                            timeout: 200 // 200mili second Response timeout
                        }
                    };

Seem the function set timeout not work? When I debug , it's go to break point at function " request.on('error', function (err) " and throw error

request error { Error: connect ETIMEDOUT 54.206.64.112:8001
    at Object._errnoException (util.js:1031:13)
    at _exceptionWithHostPort (util.js:1052:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',

not go to break point of function "request.on('requestTimeout')"

public handleError(request: any, reject: any) {
       request.on('requestTimeout', function (req) {
           console.log('request has expired');
           req.abort();
       });
       request.on('responseTimeout', function (res) {
           console.log('response has expired');

       });

       request.on('error', function (err) {
           reject(err);
           console.log('request error', err);
       });
   }

ghost avatar Feb 07 '18 06:02 ghost

do we have any support to maintain this library?

ghost avatar Feb 09 '18 08:02 ghost

Hi. In my app, the requestConfig works well. I use ver 3.1.0.

The requestConfig.timeout seems to the timeout value from the time to send the request to the time to get the response header. If your target server is down, you get error event of ETIMEDOUT.

You can test the requestConfig.timeout by using nock. Nock can delay the response header by using delay method.

https://github.com/nock/nock#delay-the-response

ghost avatar Jul 13 '19 07:07 ghost

Hello,

I also have this issue. But only on Windows ! If you set a timeout of e.g. 2 sec, it will never honour this timeout. It will always fail around 20 sec. and not within the 2 sec. I also think that this has to do with some issues of the (old) request libs in node, I also have read some problems with this timeout issues...

Is there any work/maintenance on this node-rest-client ? or is it a dead project ?

CajunDust avatar Sep 18 '20 08:09 CajunDust