When doing a long upload, I get the error ERR_CONNECTION_ABORTED after approximately 220 seconds.
My API
import fileUpload from "express-fileupload";
const port = process.env.PORT || 4000;
const app = express();
app.use(fileUpload({
useTempFiles: true,
uploadTimeout: 3600000
}));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/upload', function (req, res) {
if (!req.files || Object.keys(req.files).length === 0) {
return res.status(400).send('No files were uploaded.');
}
console.log(req)
// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
let sampleFile = req.files.sampleFile;
var fileName = req.files.sampleFile.name;
// Use the mv() method to place the file somewhere on your server
sampleFile.mv(__dirname + '/source/uploadedFreeSounds/' + fileName, function (err) {
if (err) {
console.log(err)
return res.status(500).send(err);
}
res.send('File uploaded!');
});
});
const server = app.listen(port, () => {
//createSecretToken(await r.uuid());
console.log('Server start on localhost:' + port);
});
server.on('connection', function (socket) {
// 10 minutes timeout
socket.setTimeout(3600000);
});
Friends have had the same problem After working for 15 days, the source of the problem is "server.headersTimeout = 7200000;" you can fix it by adding this code
When doing a long upload, I get the error
ERR_CONNECTION_ABORTED
after approximately 220 seconds.My API
My Client
Please help me