Skip to content
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

requestConfig set timeout not work #180

Open
ghost opened this issue Feb 7, 2018 · 3 comments
Open

requestConfig set timeout not work #180

ghost opened this issue Feb 7, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 7, 2018

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
Copy link
Author

ghost commented Feb 9, 2018

do we have any support to maintain this library?

@ghost
Copy link

ghost commented Jul 13, 2019

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

@CajunDust
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant