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

Too many ECONNRESET errors after upgrading to 8.12.0 from (8.11.4) #23237

Closed
kunalkukreja opened this issue Oct 3, 2018 · 14 comments
Closed
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@kunalkukreja
Copy link

kunalkukreja commented Oct 3, 2018

After upgrading nodejs version to 8.12.0, we have seen multiple 'ECONNRESET' socket errors. Same calls are successful in 8.11.4.

This happens when there are bulk requests being executed parallelly. The calls at the other peer are successful.

Version: 8.12.4
Platform: 64-bit (Windows)
Subsystem: https/net/tls

These calls originate from nodejs application to rails server (behind nginx with self signed certificate).
Same calls gives success on retry. On debugging further the error is thrown by net module from this line https://github.com/nodejs/node/blob/v8.12.0/lib/net.js#L622

Script to reproduce the issue:

var request = require('request'), 
fs = require('fs'), 
path = require('path'), 
ca = fs.readFileSync(path.join( 'client', 'my-private-root-ca.cert.pem')) , 
url = process.argv[3] || 'https://xyz.com/some_api/sompath/15', 
ciphers = '!aNULL:kECDH+AESGCM:ECDH+AESGCM:RSA+AESGCM:kECDH+AES:ECDH+AES:RSA+AES';

var headers = { 
     'Accept-Version': '10160205',
     Cookie: '_session_id=7157182c19271bc66108644e2531303a; path=/; secure; HttpOnly',
     Accept: 'application/json' 
};
var reqOpts = {
    url: url,
    headers: headers,
    method: 'GET',
    strictSSL: false,
    time: true,
    gzip: true,
    ca: ca,
    ciphers: ciphers
};

function makeRequest(){
    request(reqOpts, function(e,r,b){
           if(e) console.log(e);
    })
}

for(var i = 0; i < 100; i++){ makeRequest(); }

Above script works fine on 8.11.4 but thows error on 8.12.0. See below errors

> for(var i = 0; i < 100; i++){ makeRequest(); }
undefined
> { Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
{ Error: read ECONNRESET
    at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }

I will share NODE_DEBUG logs for net, tls modules

@addaleax
Copy link
Member

addaleax commented Oct 3, 2018

/cc @mafintosh @nodejs/http2

@addaleax addaleax added the http2 Issues or PRs related to the http2 subsystem. label Oct 3, 2018
@mcollina
Copy link
Member

mcollina commented Oct 4, 2018

Can you verify that the same behavior applies to the latest Node 10? We are in the process of backporting a lot of work on HTTP2 for Node 8, as the one on Node 8 was left behind.

A repro script would be extremely useful to track this down.

The behavior of that commit is correct: the socket is being abruptly interrupted. My question right now is how a ECONNRESET is being generated in the first place if all requests are arriving correctly.

@kunalkukreja
Copy link
Author

Running it with NODE_DEBUG=tls,net mode shows following logs(only pasted relevant logs for brevity)

NET 4396: connect: find host xyz.com
NET 4396: connect: dns options { family: undefined, hints: 0 }
NET 4396: _read
NET 4396: _read wait for connection
NET 4396: afterConnect
TLS 4396: start
NET 4396: _read
NET 4396: Socket._read readStart
TLS 4396: secure established
NET 4396: afterWrite 0
NET 4396: afterWrite call cb
TLS 4396: secure established
NET 4396: afterWrite 0
NET 4396: afterWrite call cb
NET 4396: onread 771
NET 4396: got data
NET 4396: _read
NET 4396: _final: not ended, call shutdown()
NET 4396: onread -4077
NET 4396: destroy
NET 4396: close
NET 4396: close handle
NET 4396: afterShutdown destroyed=true ReadableState {
  objectMode: false,
  highWaterMark: 16384,
  buffer: BufferList { head: null, tail: null, length: 0 },
  length: 0,
  pipes: null,
  pipesCount: 0,
  flowing: true,
  ended: false,
  endEmitted: false,
  reading: true,
  sync: false,
  needReadable: true,
  emittedReadable: false,
  readableListening: false,
  resumeScheduled: false,
  destroyed: true,
  defaultEncoding: 'utf8',
  awaitDrain: 0,
  readingMore: false,
  decoder: null,
  encoding: null }

Note the folowing log which triggers socket destroy.

NET 4396: onread -4077

Let me know if more details are required from my side.

@kunalkukreja
Copy link
Author

cc @nodejs Please update or add the concerned person who can help.

@AyushG3112
Copy link
Contributor

@kunalkukreja would you have a repro script by any chance?

@kunalkukreja
Copy link
Author

@AyushG3112 see this comment #23237 (comment) for script

@kunalkukreja
Copy link
Author

kunalkukreja commented Dec 6, 2018

The issue persists in v8.14.0 too.

On debugging further the issue is being caused by gzip option in the request. Passing the header 'Accept-Encoding' = 'deflate' fixes the issue. Both 'gzip' and 'gzip, deflate' values throw the error. The default value set by request library for 'Accept-Encoding' is 'gzip, deflate'. Refer this

This happens only on windows.

@bnoordhuis
Copy link
Member

It sounds like this is a server issue, if it doesn't like the 'gzip' value in the Accept-Encoding header.

Are you sure the Node.js version is the only factor? E.g., perhaps you also wittingly or unwittingly updated request when you upgraded Node.js and it now contains some changes that exacerbate it?

Can you reproduce standalone? I.e., no request, no third-party server?

@gs-ajain
Copy link

gs-ajain commented Dec 28, 2018

Facing this issue on Windows. Node - v8.12.0

My workaround: Upgraded Nodejs to v10.15.0 and the issue disappeared.

@mindfulme
Copy link

I have the same issue on node.js v8.12.0 and v10.15.0 too. I have client node.js application running through nginx trying to access public api wss://mainnet.infura.io/ws/. The initial connection is okay but the error appears on event streams

@mindfulme
Copy link

Actually, after deleting nginx completely the error disappeared, though I was using the node.js server as a client to receive data from a remote socket.

@mindfulme
Copy link

mindfulme commented Dec 31, 2018

So the solution is deleting nginx in my case

Actually, after deleting nginx completely the error disappeared, though I was using the node.js server as a client to receive data from a remote socket.

@luispeerez
Copy link

@mindfulme what did you have in your nginx config? proxy config?

@targos
Copy link
Member

targos commented Jun 13, 2020

I'm closing this issue because of its lack of recent activity. Feel free to reopen or ask that we reopen if you think that it should still be addressed.

@targos targos closed this as completed Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

No branches or pull requests

9 participants