简体   繁体   English

上传大文件nodejs multer时的ERR_CONNECTION_RESET

[英]ERR_CONNECTION_RESET when upload large file nodejs multer

I'm writing an web application that allow user to upload very large file (up to GB).我正在编写一个 web 应用程序,允许用户上传非常大的文件(高达 GB)。 My technical stack include: nodejs, express, multer and pure html.我的技术堆栈包括:nodejs、express、multer 和纯 html。 It works fine for small file.它适用于小文件。 But when I upload big file (127 MB), I got error ERR_CONNECTION_RESET after waiting a while (about 2 minutes ).但是当我上传大文件(127 MB)时,等待一段时间(大约2 分钟)后出现错误ERR_CONNECTION_RESET

I tried extended response time on server, using both req.setTimeout and res.setTimeout but it didn't help.我尝试在服务器上延长响应时间,同时使用 req.setTimeout 和 res.setTimeout 但它没有帮助。 It's may be because frontend waiting to long to get response.这可能是因为前端等待很长时间才能得到响应。

Below is the error I got:以下是我得到的错误:

在此处输入图像描述

Thank you all.谢谢你们。

Increasing the res -timeout for the corresponding upload-route should definitely work.增加相应上传路由的res -timeout 肯定会起作用。 Try doing it like this:尝试这样做:

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.

相关问题 ERR_CONNECTION_RESET:错误当我尝试使用 node.js/multer 上传大文件时,部署在 elastic beanstalk -nginx Server - ERR_CONNECTION_RESET : Error When i try to upload large files using node.js/multer , deployed at elastic beanstalk -nginx Server 当我必须存储 cookie olve 时,如何解决导致 nodejs ERR_CONNECTION_RESET 的 Chrome cookie - How to resolve Chrome cookies resulting in nodejs ERR_CONNECTION_RESET when I have to store cookies olve ERR_CONNECTION_RESET 将大文件上传到 Amazon S3 时出错 - ERR_CONNECTION_RESET Error when uploading large files to Amazon S3 Nodemailer:使用AngularJS的ERR_CONNECTION_RESET和使用POST的NodeJS - Nodemailer: ERR_CONNECTION_RESET with AngularJS and NodeJS with POST Angular 7, Node JS, IIS, pm2, ERR_CONNECTION_RESET 上传大文件 - Angular 7, Node JS, IIS, pm2, ERR_CONNECTION_RESET when upload big files net::ERR_CONNECTION_RESET 上传图片 - net::ERR_CONNECTION_RESET on uploading images NodeJS + AngularJS-一段时间后,我得到了net :: ERR_CONNECTION_RESET - NodeJS + AngularJS - after some time, I get net::ERR_CONNECTION_RESET 使用multer上传NodeJS文件 - NodeJS file upload with multer multer和nodejs上传文件 - multer and nodejs upload file 点击Node.js站点时偶尔会出现ERR_CONNECTION_RESET错误 - Occasional ERR_CONNECTION_RESET error when hitting Node.js Site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM