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

Timeout even before the HTTP request is triggered when timeout set #2773

Closed
ayazpasha2434 opened this issue Sep 20, 2017 · 2 comments
Closed
Labels

Comments

@ayazpasha2434
Copy link

Because of single-threaded nature of NodeJS event loop, even before the HTTP request is triggered to downstream application, NodeJS is self timing out resulting in HTTP request not reaching to downstream application at all. i.e by the time main thread is picking up this task the timeout has already occurred (30ms have already elapsed) & the request to downstream application never got triggered.

Ideally the timer should have started after the request is triggered but in this case it seems like the timer starts immediately which is causing this issue.

Meanwhile, I increased the timeout to 120ms from 30ms, the self-timeouts have reduced from ~2.5K per hour to 2-8 per hour.

let options = {
            url: Url, //URL to hit
            qs: params, //Query string data
            method: "GET", //Specify the method
            timeout: 30
        };
        request(options, (error, response, body) => {
            if (error) {
                return callback(new ErrorResponse(500, {error: error}));
            } else {
                return callback(null, response, body);
            }
        });

Environment details

node 5.9.1
npm 3.7.x
request ~2.67.0
OS details below
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty

Can someone from the authors/contributors look into this ASAP & help me figure out what is the exact issue here.

@dege88
Copy link

dege88 commented Sep 23, 2017

The timeout in request is not what you're expecting, it's a connection timeout.
From the docs:
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).

@stale
Copy link

stale bot commented Nov 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2018
@stale stale bot closed this as completed Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants