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 get ESOCKETTIMEDOUT #2676

Closed
Fov6363 opened this issue Jun 3, 2017 · 26 comments
Closed

request get ESOCKETTIMEDOUT #2676

Fov6363 opened this issue Jun 3, 2017 · 26 comments
Labels

Comments

@Fov6363
Copy link

Fov6363 commented Jun 3, 2017

env:

node version v7.10.0
uname -a
Linux iZ2zebqg2v1h2g7jmo9endZ 3.10.0-514.6.2.el7.x86_64 #1 SMP Thu Feb 23 03:04:39 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
request package version: "request": "^2.74.0"

and use express:4.13.4,
I find some log:

{ Error: ESOCKETTIMEDOUT
       at ClientRequest.<anonymous> (/data1/baas_server/baas_x37/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:352:8)
       at ontimeout (timers.js:386:14)
       at tryOnTimeout (timers.js:250:5)
       at Timer.listOnTimeout (timers.js:214:5) code: 'ESOCKETTIMEDOUT', connect: false }

I look the source code,get a lot annotation:

 var setReqTimeout = function() {
      // This timeout sets the amount of time to wait *between* bytes sent
      // from the server once connected.
      //
      // In particular, it's useful for erroring if the server fails to send
      // data halfway through streaming a response.
      self.req.setTimeout(timeout, function () {
        if (self.req) {
          self.abort()
          var e = new Error('ESOCKETTIMEDOUT')
          e.code = 'ESOCKETTIMEDOUT'
          e.connect = false
          self.emit('error', e)
        }
      })
    }

so i want to why the reason and how to fix the bug;
and i don't know how to trigger it,i only find it in log or find request is error;
thanks;

@liujb
Copy link

liujb commented Jul 15, 2017

@Fov6363 I have the same problem, have you fixed?

@Fov6363
Copy link
Author

Fov6363 commented Jul 17, 2017

@liujb I update redis conf, set the timeout 0

@liujb
Copy link

liujb commented Aug 2, 2017

I have solve the problem, It's not about the request. Nginx's problem.

@hktalent
Copy link

hktalent commented Aug 3, 2017

me too

node ProxyServer.js
start: 0.0.0.0:8080
events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: ESOCKETTIMEDOUT
    at ClientRequest.<anonymous> (/Users/safe/myhktools/node_modules/request/request.js:819:19)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:105:13)
    at ClientRequest.emit (events.js:207:7)
    at Socket.emitTimeout (_http_client.js:722:34)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:105:13)
    at Socket.emit (events.js:207:7)
    at Socket._onTimeout (net.js:402:8)
    at ontimeout (timers.js:469:11)

@Aaayang
Copy link

Aaayang commented Aug 17, 2017

I found this because the server used the proxy

@qieguo2016
Copy link

@liujb Hello, you said it is Nginx's problem. How do you fix this problem?

@bi-kai
Copy link

bi-kai commented Oct 28, 2017

ESOCKETTIMEDOUT is connection timeouts or read timeouts?
200 request/sec, comes up with servial this error.

@cancerberoSgx
Copy link

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

setting this options:

agent: false, pool: {maxSockets: 100}

Now the timeout can be lying so you might need to increase it.

@LucusXu
Copy link

LucusXu commented Jan 31, 2018

I got this error, sometimes with another error.

Error: read ECONNRESET
at exports._errnoException (util.js:1034:11)
at TLSWrap.onread (net.js:580:26)

@yousefissa
Copy link

Is anyone still having this issue? I'm sending a lot of requests at once and am having it.

@greenais
Copy link

The same is here - with single put request to node express -based worker.
No proxy, no streaming, just single request which starts several async promises dealing with DB on worker side.

Suggested agent: false, pool: {maxSockets: 100} in request options didn't help.

Any suggestions from mantainers?

@deluo
Copy link

deluo commented Apr 24, 2018

agent: false, pool: {maxSockets: 100}
After I set above options errors reduce from 55 to 8.
And then I set maxSockets:200 . only one error left
I don't know the reason but it does work

@anosulchik
Copy link

anosulchik commented Mar 7, 2019

It happens to me with request 2.88.0, we occasionally get ESOCKETTIMEDOUT for those requests which were sent out from our app and were processed on receiving part with 200 status code. It looks like a bug somewhere in between request or https modules. Again, request lib throws exception to https request that is processed with 200 http status code. Any ideas are welcome. The problem is easily reproducible on our side (about every 200's request fails) so if you guys interested I can provide more details.

P.S. We did a workaround by implementing retries for failed requests.

@MumiaIrrequieta
Copy link

Hi,
The documentation says there are "connection timeouts and read timeouts".
Is there a way to set each of them separately?

I'm having a connection timeout sometimes due to an unidentified network issue, and I would like to timeout as fast as I can to be able to retry the request without having to wait for the full timeout that is considering the time to receive the answer.
Thanks.

@hktalent
Copy link

fix to:

EventEmitter = require('events').EventEmitter
EventEmitter.prototype._maxListeners = n_maxLs;
var _fnNull = function(e){if(program && program.verbose)console.log(e)};
process.on('uncaughtException', _fnNull);
process.on('unhandledRejection', _fnNull);

EventEmitter.defaultMaxListeners = n_maxLs;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

@MumiaIrrequieta @anosulchik @deluo

@MumiaIrrequieta
Copy link

fix to:

EventEmitter = require('events').EventEmitter
EventEmitter.prototype._maxListeners = n_maxLs;
var _fnNull = function(e){if(program && program.verbose)console.log(e)};
process.on('uncaughtException', _fnNull);
process.on('unhandledRejection', _fnNull);

EventEmitter.defaultMaxListeners = n_maxLs;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

@MumiaIrrequieta @anosulchik @deluo

How does this helps setting separate timeouts?
What's the difference between the last couple of lines?

@anosulchik
Copy link

It doesn't look like a fix for ESOCKETTIMEDOUT for me either. @hktalent can you give more info on this please?

@SirLancelot-OG
Copy link

Also having this issue. I send out thousands of requests every minute; after about 1 week of running all the connections just immediately start responding with ESOCKETTIMEDOUT.

@firasdib
Copy link

firasdib commented May 9, 2019

@SirLancelot-OG did you solve it?

@SirLancelot-OG
Copy link

I poll data every minute, looks like there were some APIs sporadically slowing down and causing the total request to run over a minute which stacked up and led to timeouts. Didn't have the proper logging in place.

Have now moved to using websockets for my data!

@brion-fuller
Copy link

I get this issue with every request consistently. I will make a request and the request does pipe and complete. But if timeout is 10 seconds, I will allows get an 'ESOCKETTIMEDOUT' after 10 seconds of a single request.

@lucaswxp
Copy link

Anyone fixed this?

@weiweian90
Copy link

I have solve the problem, It's not about the request. Nginx's problem.

how to solve the Nginx's problem

@krestivo-kdinfotech
Copy link

We are having this and it is failing builds... what is this mysterious mystical nginx fix??

@vigneshkindia
Copy link

facing this issue recently. anyone can help ?

@stale
Copy link

stale bot commented Jan 9, 2022

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 Jan 9, 2022
@stale stale bot closed this as completed Apr 17, 2022
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