Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

offen: Asp net Core 2 hängt sich auf beim Upload von großen Dateien

23.08.2018 (👁12168)

Fileupload bei Asp.net core hängt sich auf…

Problem

Beim Upload von sehr großen Dateien zum Asp.Net Core Server hängt sich der Upload nach einiger Zeit oder Dateigrößen auf.

Fehlermeldung:

502 – Web server received an invalid response while acting as a gateway or proxy server.

 

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

 

 

Versuch 1: webconfig sessionState

Einstellen der sessionstate timeout in der asp.net core web.config.

Falsche Lösung in asp.net core üblicherweise in Netz Foren:

  <system.web>

    <sessionState

      mode="InProc"

      cookieless="true"

      timeout="30" />

  </system.web>

Folge 1:

Keine Auswirkung auf Timeout

Fehlermeldung:

502 – Web server received an invalid response while acting as a gateway or proxy server.

 

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

 

 

Versuch 2: web.config->aspNetCore einstellen

: aspNetCore in web.config

Fehlercode bei einsetzen der aspnetcore attributs

    <aspNetCore 

        requestTimeout="00:20:00"

  processPath="%LAUNCHER_PATH%"

  arguments="%LAUNCHER_ARGS%"

  stdoutLogEnabled="true"

  stdoutLogFile=".\logs\stdout"          

      />

Folge beim Upload einer Datei

Fehlermeldung

404 - File or directory not found.

The resource you are looking for might have been removed, had its name changed, or is temporarily

 

 

Versuch 3: einstellen von program.cs->kestrel.timeout

 

Einfügen in BuildWebHost->UseKestrel->KeepAliveTimeout

.UseKestrel(s =>{s.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(30);})

 

Code in program.cs (unter asp.net core 2)

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore;

using Microsoft.AspNetCore.Hosting;

using Microsoft.Extensions.Configuration;

using Microsoft.Extensions.Logging;

 

namespace Readdy

{

    public class Program

    {

        public static void Main(string[] args)

        {

            BuildWebHost(args).Run();

        }

 

        public static IWebHost BuildWebHost(string[] args) =>

            WebHost.CreateDefaultBuilder(args)

            

                .UseStartup<Startup>()

                .UseIISIntegration() //*old Core1 ..2?

            

                //< set upload timeout >

                .UseKestrel(s =>{s.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(30);})

                //</ set upload timeout >

                .Build()

            ;

    }

}

 

 

Folge beim Upload

502 - Web server received an invalid response while acting as a gateway or proxy server.

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

 

Versuch 4: einstellen von program.cs->kestrel.timeout

Alle Limit Parameter des Kestrel-Servers maximieren:

            .UseKestrel(s =>{

                s.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(120);

                s.Limits.MaxRequestBodySize = null;

                s.Limits.MaxRequestBufferSize = null;

                s.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(120);

            })

In Asp.Net Core 2:

Program.cs

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore;

using Microsoft.AspNetCore.Hosting;

using Microsoft.Extensions.Configuration;

using Microsoft.Extensions.Logging;

 

namespace Readdy

{

    public class Program

    {

        //--------< class: Program >--------

        public static void Main(string[] args)

        {

            BuildWebHost(args).Run();

        }

 

        public static IWebHost BuildWebHost(string[] args) =>

            WebHost.CreateDefaultBuilder(args)

            .UseStartup<Startup>()

                

            .UseIISIntegration() //*!! Important Asp.Net Core2 on IIS !!

            

            //< set upload timeout >

            .UseKestrel(s =>{

                s.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(120);

                s.Limits.MaxRequestBodySize = null;

                s.Limits.MaxRequestBufferSize = null;

                s.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(120);

            })

            //</ set upload timeout >

 

            .Build()

            ;

        //--------</ class: Program >--------

    }

}

 

Visual Studio im Projekt:

 

Fehler beim Uplod von großen Files

502 - Web server received an invalid response while acting as a gateway or proxy server.

 

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

 

Versuch 5: Einstellen von Publish->web.config->requestTimeout

Anpassen der Ausgabe-web.config

In der Ausgabe durch asp.net core Projekt->Publish wird die web.config neu erzeugt.

In dieser automatisch angepassten web.config Datei wird die Zeile handlers und aspNeCore automatisch von Asp.Net Core in Visual Studio erzeugt.

Hier passe ich in der Zeile aspNetCore an und füge das Attribut requestTimeout ein

<aspNetCore processPath="dotnet" arguments=".\Readdy.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" requestTimeout="01:00:00"/>

 

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <system.webServer>

    <security>

      <requestFiltering>

        <!-- Limit Upload to 700MB  -->

        <requestLimits maxAllowedContentLength="3000000000" />

      </requestFiltering>

    </security>

    <handlers>

      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />

    </handlers>

    <aspNetCore processPath="dotnet" arguments=".\Readdy.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" requestTimeout="01:00:00"/>

  </system.webServer>

</configuration>

 

Folge:

Noch immer Abbruch bei Upload von großen Dateien