KevinJump / uSync

Database syncing tool for Umbraco CMS
https://jumoo.co.uk/usync/
Mozilla Public License 2.0
112 stars 65 forks source link

Import Sync-Pack: Failed to upload 413 #687

Closed urosSowa closed 1 week ago

urosSowa commented 1 week ago

Describe the bug I want to export the whole content from production to development environment using uSync.Complete Exporter/Importer. Our exported .usync file consists of content and media is around 800MB.

In development appsettings.json I have:

  "Umbraco": {
    "CMS": {
      "Runtime": {
        "MaxRequestLength": 1500000 // ~ 1.5GB

I get the error: Failed to upload 413

In log there is always max request body size limit 500MB error, even when I set MaxRequestLength to 50000 (~50MB)

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large. The max request body size is 500000000 bytes.
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2MessageBody.OnReadStarting()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.TryStartAsync()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2MessageBody.ReadAsync(CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.BufferedReadStream.EnsureBufferedAsync(Int32 minCount, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.MultipartReader.ReadNextSectionAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
   at Umbraco.Extensions.HttpRequestExtensions.GetUfprt(HttpRequest request)
   at Umbraco.Cms.Web.Website.Routing.EagerMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
   at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|10_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 112
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
   at uSync.Exporter.uSyncExporterUploadMiddleware.InvokeAsync(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

To Reproduce Steps to reproduce the behavior:

  1. Open Backoffice and go to Setings -> uSync -> Exporter
  2. Click on Import Sync-Pack and select uSync file that is larger than 500MB
  3. Click Import
  4. See error: Failed to upload 413

Expected behavior MaxRequestLength should apply also to uSync, large uSync files (>500MB) should be imported successfully.

About your Site (please complete the following information):

Additional context Add any other context about the problem here.

KevinJump commented 1 week ago

Hi, If you are using IIS then I think you also need to set the value in the web.config (if you are using something else on linxu, i guess there are settings there too?)

if you want to only set the values for uSync Exporter then we have some docs on that too. (i am not sure you need to update maxRequestLength anymore)

https://docs.jumoo.co.uk/usync/complete/reference/upload

I just did a quick test. below let me upoad a 800mb file into the exporter's import method.

  "Umbraco": {
    "CMS": {
      "Runtime": {
        "MaxRequestLength": 1500000
      },
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering>
                <!-- ~ Below is the number of bytes allowed, 4GB is the maximum -->
                <requestLimits maxAllowedContentLength="900000000" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
urosSowa commented 1 week ago

Hi, thank you for quick answer.

As it seems the issue is only with Kestrel which we're using.

I saw the documentation but it just covers the IIS :(.