我有一个节点服务器,我用作我的iPhone应用程序的API服务器。此时,当应用程序正在下拉一些随机文件(比如说图片或视频文件)时,我会发现随机崩溃。
我是节点的新手,我真的不明白为什么会崩溃。有关服务文件的服务器代码很多。我只是将文件放在我的“uploads”目录中。它大部分时间都有效,但随后出现间歇性崩溃。
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
我在SO上发现了一些帖子似乎说静态行应该是最后一个,所以这是我的app.configure以供参考。
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')));
});
------------------------------------------------------------------------
任何帮助将不胜感激!