help icon indicating copy to clipboard operation
help copied to clipboard

Error: read ECONNRESET

Open jiuhuan opened this issue 5 years ago • 6 comments

  • Version: v15.3.0
  • Platform: Darwin
  • Subsystem: MacOS 11.0.1

What steps will reproduce the bug?

The code That I created.

const http2 = require('http2');
const fs = require('fs');

const http2Server = http2.createSecureServer({
  key: fs.readFileSync('localhost-privkey.pem'),
  cert: fs.readFileSync('localhost-cert.pem')
});
http2Server.on('error', (err) => console.error(err));

http2Server.on('request', (req, res)=>{
  console.log(req.httpVersion);
  console.log(req.headers);
  res.end('hello, word.')
});

http2Server.listen(1443, ()=> {
  console.log('http2 started 1443')
});

I use 'wget' to send the request.

wget --no-check-certificate https://localhost:1443

results:

node:events:353
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:213:20)
Emitted 'error' event on TLSSocket instance at:
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:80:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}

jiuhuan avatar Dec 03 '20 09:12 jiuhuan

@nodejs/http2

targos avatar Dec 06 '20 14:12 targos

The error isn't coming from the server it's coming from the request or response being closed early, you should probably add an error handler on the request/response streams as well.

benjamingr avatar Dec 06 '20 16:12 benjamingr

Anyway this is not a bug from what I can tell - so I'll move to nodejs/help

benjamingr avatar Dec 06 '20 16:12 benjamingr

The error isn't coming from the server it's coming from the request or response being closed early, you should probably add an error handler on the request/response streams as well.

I use nodejs for start http2 server, but at receiving a incorrect http2 protocol request, throws an error and terminates the process, which is so serious that I personally think this error should have occurred in the Http2Server.on (' error ') event.

jiuhuan avatar Dec 07 '20 10:12 jiuhuan

which is so serious that I personally think this error should have occurred in the Http2Server.on (' error ') event.

But the error is part of the request stream and not the server :]

Node.js crashes on uncaught exceptions - event emitters in Node typically don't "propagate" automatically afaik.

benjamingr avatar Dec 07 '20 10:12 benjamingr

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar May 11 '24 01:05 github-actions[bot]

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar Jun 10 '24 01:06 github-actions[bot]