I have a node server that I'm using as an API server to my iPhone application. At this point, I'm getting random crashes when the app is pulling down some random files (like, say a picture or a video file).
I'm new to node and I really dont understand why this would be crashing. There isnt much server code with regards to the serving of the files. I'm simply putting the files in my "uploads" directory. It works most times, but then there are intermittent crashes.
stream.js:81
throw er; // Unhandled stream error in pipe.
^
Error: socket hang up
at createHangUpError (http.js:1360:15)
at ServerResponse.OutgoingMessage._writeRaw (http.js:507:26)
at ServerResponse.OutgoingMessage._send (http.js:476:15)
at ServerResponse.OutgoingMessage.write (http.js:749:16)
at ServerResponse.module.exports.res.write (/Users/sigma/Development/Node.js/sigma-app/node_modules/express/node_modules/connect/lib/middleware/compress.js:82:17)
at ondata (stream.js:38:26)
at EventEmitter.emit (events.js:96:17)
at ReadStream._emitData (fs.js:1368:10)
at afterRead (fs.js:1350:10)
at Object.wrapper [as oncomplete] (fs.js:362:17)
Process finished with exit code 1
I found some posts on SO that seemed to say that the static line should be last, so here is my app.configure for reference.
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.use(express.bodyParser({uploadDir:'./tmp'}));
app.use(express.logger());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({
secret : "somesecret"
}));
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.compress());
app.use(express.static(path.join(__dirname, 'uploads')));
});
------------------------------------------------------------------------
Any help would be appreciated!