使用Connect Multiparty处理节点js中的请求

Error: Request aborted at IncomingMessage.onReqAborted (D:\ProjectName\node_modules\express\node_modules\connect\node_modules\multiparty\index.js:131:17) at IncomingMessage.EventEmitter.emit (events.js:92:17) at abortIncoming (http.js:1911:11) at Socket.serverSocketCloseListener (http.js:1923:5) at Socket.EventEmitter.emit (events.js:117:20) at TCP.close (net.js:466:12) 

使用连接多方中间件在节点js中上传多个文件时出现此错误。 我甚至没有上传大文件。 其不超过50MB。 当上传文件时断开networking连接时出现此错误。 有没有办法来处理这个错误。

你应该使用Multer js来上传文件。

在我的情况下,我可以解决添加更多的请求/响应超时。

如果您使用快递:

 var server = app.listen(app.get('port'), function() { debug('Express server listening on port ' + server.address().port); }); server.timeout = 1000 * 60 * 10; // 10 min 

Connect / Express还有一个中间件: https : //github.com/expressjs/timeout

如果你不使用快递,只能使用香草节点:

 var http = require('http'); var server = http.createServer(function (req, res) { setTimeout(function() { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }, 200); }).listen(3000, '127.0.0.1'); server.timeout = 1000 * 60 * 10; // 10 min console.log('Server running at http://127.0.0.1:3000/');