'NodeJS - timeout on large file download
I am trying to download a fairly large file (500MB) from an NodeJS API endpoint, but the following code appears times out with a 504 Gateway Timeout:
async download(res: Response) {
const path = `${this.EXCEL_SAVE_DIR}/report.xlsx`;
try {
if (fs.existsSync(path)) {
res.download(path);
} else {
logger.debug(`download -> file not found at: ${path} `);
}
} catch (err) {
logger.debug(`download -> error: ${JSON.stringify(err)}`);
}
}
Is it possible to avoid these timeouts?
Solution 1:[1]
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
Increase proxy time out in Nginx
proxy_read_timeout 600s;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sojin |
