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) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok my bad, I had another node instance running elsewhere. Now I have this different error (still not a socket hangup:)