Created
March 21, 2013 18:23
-
-
Save Philmod/5215399 to your computer and use it in GitHub Desktop.
This is simple way to reproduce the socket hang up. Hope it can help.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install express supertest | |
// node socketHangUp.js | |
/** | |
* Express server. | |
*/ | |
var express = require('express') | |
, request = require('supertest') | |
; | |
var app = express(); | |
app.configure(function() { | |
app.use(express.bodyParser()); | |
app.use(app.router); | |
}); | |
app.get('/', function(req, res) { | |
res.send('hello world'); | |
}); | |
/** | |
* Requests. | |
*/ | |
var i = 0 | |
, max = 1000 | |
, reqfn = function () { | |
request(app) | |
.get('/') | |
.end(function(error, res){ | |
console.log('i = ', i++); | |
if (i<max) reqfn(); | |
}); | |
request(app) | |
.get('/') | |
.end(function(error, res){ | |
console.log('i = ', i++); | |
if (i<max) reqfn(); | |
}); | |
}; | |
reqfn(); | |
/* | |
i = 1996 | |
events.js:72 | |
throw er; // Unhandled 'error' event | |
^ | |
Error: socket hang up | |
at createHangUpError (http.js:1417:15) | |
at Socket.socketOnEnd [as onend] (http.js:1513:23) | |
at Socket.g (events.js:175:14) | |
at Socket.EventEmitter.emit (events.js:117:20) | |
at _stream_readable.js:870:14 | |
at process._tickCallback (node.js:415:13) | |
*/ |
I'm on node 0.8.8 and express is v3.2.0
Ok my bad, I had another node instance running elsewhere. Now I have this different error (still not a socket hangup:)
i = 1016
i = 1017
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: connect EMFILE
at errnoException (net.js:768:11)
at connect (net.js:644:19)
at Socket.connect (net.js:709:9)
at dns.js:71:18
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran:
And this is what I got: