错误502下载文件Angular 11时错误的网关?
我从Angular 11
上下载zip文件
。
下载大文件时,我会面临问题,但是小文件没有任何问题。
我下载的大文件有尺寸2.397 kb。
将需要7分钟才能完成下载,但是2分钟后给我错误502 BAD GATEWAWAY。
它从本地PC下载文件,而无需任何问题,但是尝试从远程服务器发布下载文件时,给我错误502 BAD GATEWAY
。
那么如何解决此问题,为什么我会遇到此错误?
e {headers: n, status: 502, statusText: 'Bad Gateway', url: 'https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp', ok: false, …}
error: Blob
size: 1477
type: "text/html"
[[Prototype]]: Blob
headers: n
lazyInit: ƒ ()
lazyUpdate: null
normalizedNames: Map(0) {size: 0}
[[Prototype]]: Object
message: "Http failure response for https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp: 502 Bad Gateway"
name: "HttpErrorResponse"
ok: false
status: 502
statusText: "Bad Gateway"
url: "https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp"
[[Prototype]]: Object
constructor: ƒ e(e)
[[Prototype]]: Object
我尝试了什么
web api
[Route("ExportNxp")]
public IActionResult ExportNxp(bool areIdentical)
{
if (areIdentical == false)
{
return OK("Not Matched Excel");
}
else
{
return PhysicalFile(zipPath, "application/zip", Path.GetFileName(zipPath));
}
}
service.ts
PostUploadzipNxp(file:any):Observable<any>
{
formData.append('file', file,file.name);
return this.http.post('https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp/', formData,{observe: 'response', responseType: 'blob' });
}
component.ts
this._dataService.PostUploadzipNxp(this.fileToUpload)
.subscribe(blob => {
saveAs(blob.body, this.fileToUpload?.name +'.zip');
});
I work on download zip file
from angular 11
.
I face issue when download Large files but small files not have any issue .
Large file i download have size 2.397 kb.
it will take 7 minutes to finish download but after 2 minute give me error 502 bad gateway.
it download file from local pc without any issue but when try to download file from remote server publish give me error 502 bad gateway
.
so How to solve this issue and why I get this error ?
e {headers: n, status: 502, statusText: 'Bad Gateway', url: 'https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp', ok: false, …}
error: Blob
size: 1477
type: "text/html"
[[Prototype]]: Blob
headers: n
lazyInit: ƒ ()
lazyUpdate: null
normalizedNames: Map(0) {size: 0}
[[Prototype]]: Object
message: "Http failure response for https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp: 502 Bad Gateway"
name: "HttpErrorResponse"
ok: false
status: 502
statusText: "Bad Gateway"
url: "https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp"
[[Prototype]]: Object
constructor: ƒ e(e)
[[Prototype]]: Object
what i have tried
web api
[Route("ExportNxp")]
public IActionResult ExportNxp(bool areIdentical)
{
if (areIdentical == false)
{
return OK("Not Matched Excel");
}
else
{
return PhysicalFile(zipPath, "application/zip", Path.GetFileName(zipPath));
}
}
service.ts
PostUploadzipNxp(file:any):Observable<any>
{
formData.append('file', file,file.name);
return this.http.post('https://pn.xxx.com:7072/api/Z2Delivery/ExportNxp/', formData,{observe: 'response', responseType: 'blob' });
}
component.ts
this._dataService.PostUploadzipNxp(this.fileToUpload)
.subscribe(blob => {
saveAs(blob.body, this.fileToUpload?.name +'.zip');
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,ASP.NET核心请求超时为2分钟,您可以通过program.cs
in .net core 6.0
in .NET CORE 3.1中的eateAliveTime out进行更改。
By default, ASP.NET Core request time out is 2 minutes, and you can change it via KeepAliveTimeout in program.cs file
in .net core 6.0
in .net core 3.1