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

Request getting ESOCKETTIMEDOUT consistently when all other clients work (http://www.bestbuy.com) #2738

Closed
aml11 opened this issue Aug 10, 2017 · 6 comments
Labels

Comments

@aml11
Copy link

aml11 commented Aug 10, 2017

Hello,

very easy to reproduce and always happens!

const request = require('request');
const axios = require('axios');
const url = 'http://www.bestbuy.com/';
request({
    url: url,
    timeout: 5000
}, (error, response, body) => {
    if (!error)
        console.log(`request got ${response.statusCode}`);
    else
        console.error(`request got an error`, error);
});

axios.get(url).then((ret) => {
    console.log(`Axios got ${ret.status}`);
});

outputs:

Axios got 200
request got an error { Error: ESOCKETTIMEDOUT
    at ClientRequest.<anonymous> (/Users/amir/dev/test/testVideosFb/node_modules/request/request.js:819:19)
    at Object.onceWrapper (events.js:293:19)
    at emitNone (events.js:86:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.emitTimeout (_http_client.js:679:10)
    at Object.onceWrapper (events.js:293:19)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:188:7)
    at Socket._onTimeout (net.js:345:8)
    at ontimeout (timers.js:380:14) code: 'ESOCKETTIMEDOUT', connect: false }

My environment is node 7.7.2/8.3.0 and request@2.81.0

@Abichai
Copy link

Abichai commented Sep 1, 2017

It would be nice to have some feedback on this ESOCKETTIMEOUT issue since I got it too and I don't found any way to solve this issue without changing this module.

Is the ESOCKETTIMEOUT related to an issue with the socket pooling ? I thought soo so I did disable socket pooling in node with

`var http = require('http');
http.globalAgent.maxSockets = Infinity;

var https = require('https');
https.globalAgent.maxSockets = Infinity;`

but it didn't change anything about not getting the ESOCKETTIMEOUT someone as a solution for this error ?

@icezohu
Copy link

icezohu commented Oct 24, 2017

same issue for me

@cancerberoSgx
Copy link

I found if there are too many async requests, then ESOCKETTIMEDOUT exception happens in linux. The workaround I've found is doing this:

setting this options to request():

agent: false, pool: {maxSockets: 100}

Notice that after that, the timeout can be lying so you might need to increase it.

@8acker
Copy link

8acker commented Jan 9, 2018

Same issue here +1
agent: false, pool: {maxSockets: 100} didn't help

@msjonker
Copy link

I think bestbuy.com may be blocking the request due to the default headers being sent from request. If the request is made with the same headers that the axios request is sending, it does not time out:

const request = require('request');
const axios = require('axios');
const url = 'http://www.bestbuy.com/';
request({
  url: url,
  timeout: 5000,
  headers: {
    "Accept": "application/json, text/plain, */*",
    "User-Agent": "axios/0.18.0"
  }
}, (error, response, body) => {
  if (!error)
    console.log(`request got ${response.statusCode}`);
  else
    console.error(`request got an error`, error);
});

axios.get(url).then((ret) => {
  console.log(`Axios got ${ret.status}`);
});

@stale
Copy link

stale bot commented Feb 28, 2019

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.

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

6 participants