错误502下载文件Angular 11时错误的网关?

发布于 2025-01-21 04:53:18 字数 1776 浏览 0 评论 0原文

我从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的黑色迷你裙 2025-01-28 04:53:18

默认情况下,ASP.NET核心请求超时为2分钟,您可以通过program.cs

in .net core 6.0

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(t =>
{
  t.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(15);
});

in .NET CORE 3.1中的eateAliveTime out进行更改。

 public static void Main(string[] args)
 {
  CreateWebHostBuilder(args).Build().Run();
 }

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
  WebHost.CreateDefaultBuilder(args)
    .UseStartup<Startup>()
    .ConfigureKestrel(o => { o.Limits.KeepAliveTimeout =  TimeSpan.FromMinutes(10); });

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

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(t =>
{
  t.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(15);
});

in .net core 3.1

 public static void Main(string[] args)
 {
  CreateWebHostBuilder(args).Build().Run();
 }

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
  WebHost.CreateDefaultBuilder(args)
    .UseStartup<Startup>()
    .ConfigureKestrel(o => { o.Limits.KeepAliveTimeout =  TimeSpan.FromMinutes(10); });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文