question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:25
  • Comments:6

github_iconTop GitHub Comments

40reactions
cancerberoSgxcommented, Nov 4, 2017

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.

17reactions
msjonkercommented, Feb 28, 2018

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}`);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - request npm module - resolve ESOCKETTIMEDOUT
I am using request npm module and making upstream requests in a loop approx 100 requests per second. The timeout has been set...
Read more >
Error: ESOCKETTIMEDOUT with REST request
All of a sudden we are getting plastered with Error: ESOCKETTIMEDOUT when waiting for a response to our requests. This does not always...
Read more >
How to resolve esockettimedout - Caritas Castellaneta
Simplest Example to Reproduce request({ method: 'GET', 10-Aug-2017 Request getting ESOCKETTIMEDOUT consistently when all other clients work (http://www.
Read more >
Untitled
If the other side has won, L archeologo subacqueo, Media frequenza colori, ... All premier league results, Ford granada 2.8, How the click...
Read more >
[Code example]-Appium and protractor just opens the app but ...
I have developed the mobile test framework using appium and protractor. When I invoke the ... passing request on via HTTP proxy [JSONWP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found