3

It's a super simple express app. After some time WITH NOT REQUESTS, just sitting idle this error will happen:

Example app listening on port 80!
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:1022:11)
    at TCP.onread (net.js:572:26)

For reference here is the code

"use strict"

var express = require('express');

var app = express();

app.get('/', function(req, res) {
    res.end('hello')
})

app.listen(80, function () {
    console.log('Example app listening on port 80!')
})
Sean256
  • 2,849
  • 4
  • 30
  • 39

1 Answers1

1

socket receive a 'error' event,we should use 'error' event listener, otherwise it will propagate and crash you process.

var server = http.createServer(function(request, response){ ... ... });
server.on('error', function(err) { ... ... });
server.on('listening', function(err) { ... ... });
Mathankumar K
  • 621
  • 1
  • 6
  • 14