【问题标题】:Node.js Error: Request aborted in File upload formidableNode.js 错误:在文件上传强大的请求中止
【发布时间】:2014-04-06 23:06:55
【问题描述】:

我正在使用强大的模块https://github.com/felixge/node-formidable 来上传图片。我创建了一个单独的新项目和文件上传完美。

但是当我将它集成到我现有的项目中时。我收到以下错误:-

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)

知道如何解决这个问题吗?

我尝试了 ON 事件:-

form.on('progress', function (bytesReceived, bytesExpected) {
        console.log('PROGRESS');
        console.log(bytesReceived);
        console.log(bytesExpected);
    });

上面代码的结果是:-

PROGRESS
0
488

它没有超越这个。

【问题讨论】:

    标签: node.js gridfs


    【解决方案1】:

    尝试在你的 app.js 中删除它:

    app.use(express.bodyParser());
    

    【讨论】:

    • 你能解释一下为什么删除它会有帮助吗?我认为需要正文解析器来获取发布请求的请求?
    【解决方案2】:

    对于 OP 来说可能有点晚了,但对于其他人来说:只需像这样设置/增加 nodejs 超时:

    server.timeout = 1000 * 60 * 10; // 10 mins
    

    强大的使用这个设置,之后它会抛出“abort”和“error”事件。详情可以查看this answer

    【讨论】:

    • 我遇到了 fluent-ffmpeg 处理时间过长(超过 2 分钟的默认设置)的问题,导致 请求中止
    【解决方案3】:

    对于不推荐使用 body-parser 的更高版本的 express(即 express@^4.x),请删除、删除或注释掉您的条目 .js.ts 文件中的任何 app.use(express.json())

    【讨论】:

      猜你喜欢
      • 2014-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-10
      • 2021-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多