繁体   English   中英

上传大文件nodejs multer时的ERR_CONNECTION_RESET

[英]ERR_CONNECTION_RESET when upload large file nodejs multer

我正在编写一个 web 应用程序,允许用户上传非常大的文件(高达 GB)。 我的技术堆栈包括:nodejs、express、multer 和纯 html。 它适用于小文件。 但是当我上传大文件(127 MB)时,等待一段时间(大约2 分钟)后出现错误ERR_CONNECTION_RESET

我尝试在服务器上延长响应时间,同时使用 req.setTimeout 和 res.setTimeout 但它没有帮助。 这可能是因为前端等待很长时间才能得到响应。

以下是我得到的错误:

在此处输入图像描述

谢谢你们。

增加相应上传路由的res -timeout 肯定会起作用。 尝试这样做:

function extendTimeout (req, res, next) {
  // adjust the value for the timeout, here it's set to 3 minutes
  res.setTimeout(180000, () => { // you can handle the timeout error here })
  next();
})

app.post('/your-upload-route', extendTimeout, upload.single('your-file'), (req, res, next) => {
  // handle file upload
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM