fix: large mp4 file download does not work
Closed this issue · 2 comments
FritzTheCat9 commented
[20:27:46 ERR d6e13ed3-aff8-4161-8c16-ecaa737d2ea5] [UnitOfWork] Rollback Transaction "System.Threading.Tasks.TaskCanceledException: A task was canceled.\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\r\n at YoutubeLinks.Api.Behaviors.UnitOfWorkBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Behaviors\\UnitOfWorkBehavior.cs:line 39"
[20:27:46 ERR d6e13ed3-aff8-4161-8c16-ecaa737d2ea5] An error occurred using a transaction.
[20:27:46 INF d6e13ed3-aff8-4161-8c16-ecaa737d2ea5] Executed endpoint '"HTTP: POST /api/links/download"'
[20:27:46 ERR d6e13ed3-aff8-4161-8c16-ecaa737d2ea5] [Api Exception] "System.Threading.Tasks.TaskCanceledException: A task was canceled.\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.RollbackAsync(CancellationToken cancellationToken)\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.RollbackAsync(CancellationToken cancellationToken)\r\n at YoutubeLinks.Api.Behaviors.UnitOfWorkBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Behaviors\\UnitOfWorkBehavior.cs:line 50\r\n at YoutubeLinks.Api.Behaviors.UnitOfWorkBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Behaviors\\UnitOfWorkBehavior.cs:line 52\r\n at YoutubeLinks.Api.Behaviors.ValidationBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Behaviors\\ValidationBehavior.cs:line 37\r\n at YoutubeLinks.Api.Behaviors.LoggingBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Behaviors\\LoggingBehavior.cs:line 27\r\n at YoutubeLinks.Api.Features.Links.Commands.DownloadLinkFeature.<>c.<<Endpoint>b__0_0>d.MoveNext() in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Features\\Links\\Commands\\DownloadLinkFeature.cs:line 19\r\n--- End of stack trace from previous location ---\r\n at Microsoft.AspNetCore.Http.RequestDelegateFactory.ExecuteTaskResult[T](Task`1 task, HttpContext httpContext)\r\n at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass102_2.<<HandleRequestBodyAndCompileRequestDelegateForJson>b__2>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)\r\n at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at YoutubeLinks.Api.Exceptions.ExceptionMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\\Users\\bartl\\source\\repos\\YoutubeLinks\\YoutubeLinks.Api\\Exceptions\\ExceptionMiddleware.cs:line 21"
[20:27:46 INF d6e13ed3-aff8-4161-8c16-ecaa737d2ea5] Request finished "HTTP/1.1" "POST" "http"://"localhost:5000""""/api/links/download""" - 500 null "application/json" 248424.3078ms
[20:28:09 INF 35b2f83b-489d-4771-80e7-f60f09fa522a] Request starting "HTTP/1.1" "OPTIONS" "http"://"localhost:5000""""/api/links/download""" - null null
[20:28:09 INF 35b2f83b-489d-4771-80e7-f60f09fa522a] CORS policy execution successful.
[20:28:09 INF 35b2f83b-489d-4771-80e7-f60f09fa522a] Request finished "HTTP/1.1" "OPTIONS" "http"://"localhost:5000""""/api/links/download""" - 204 null null 6.4492ms
[20:28:09 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] Request starting "HTTP/1.1" "POST" "http"://"localhost:5000""""/api/links/download""" - "application/json; charset=utf-8" 30
[20:28:09 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] CORS policy execution successful.
[20:28:09 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] Executing endpoint '"HTTP: POST /api/links/download"'
[20:28:09 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] [MediatR] Starting request "DownloadLink+Command"
[20:28:36 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] [UnitOfWork] Commited Transaction
[20:28:36 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] [MediatR] Completed request "DownloadLink+Command" in 00:00:27.4841703
[20:28:36 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] Sending file with download name '"Alessandra - Queen of Kings (Official Music Video).mp4"'.
[20:28:36 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] Executed endpoint '"HTTP: POST /api/links/download"'
[20:28:36 INF 73b61958-4f19-4ef5-8331-3da7e75ff9be] Request finished "HTTP/1.1" "POST" "http"://"localhost:5000""""/api/links/download""" - 200 215190800 "audio/mpeg" 27723.572ms
[20:28:38 INF 1e9b91ce-9d66-46cb-b91f-47bcf6a40851] Request starting "HTTP/1.1" "OPTIONS" "http"://"localhost:5000""""/api/links/all""" - null null
[20:28:38 INF 1e9b91ce-9d66-46cb-b91f-47bcf6a40851] CORS policy execution successful.
[20:28:38 INF 1e9b91ce-9d66-46cb-b91f-47bcf6a40851] Request finished "HTTP/1.1" "OPTIONS" "http"://"localhost:5000""""/api/links/all""" - 204 null null 3.5523ms
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] Request starting "HTTP/1.1" "POST" "http"://"localhost:5000""""/api/links/all""" - "application/json; charset=utf-8" 88
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] CORS policy execution successful.
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] Executing endpoint '"HTTP: POST /api/links/all"'
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] [MediatR] Starting request "GetAllLinks+Query"
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] [MediatR] Completed request "GetAllLinks+Query" in 00:00:00.0097563
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] Setting HTTP status code 200.
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] Writing value of type '"PagedList`1"' as Json.
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] Executed endpoint '"HTTP: POST /api/links/all"'
[20:28:38 INF e4dafeea-4f46-41c9-a759-4f059bef8854] Request finished "HTTP/1.1" "POST" "http"://"localhost:5000""""/api/links/all""" - 200 null "application/json; charset=utf-8" 20.4992ms
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Out of memory
System.OutOfMemoryException: Out of memory
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.MemoryStream.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
--- End of stack trace from previous location ---
at System.Net.Http.HttpContent.<CopyToAsync>g__WaitAsync|56_0(ValueTask copyTask)
at YoutubeLinks.Blazor.Pages.Links.Links.DownloadPlaylistLink(Int32 id, YoutubeFileType youtubeFileType) in C:\Users\bartl\source\repos\YoutubeLinks\YoutubeLinks.Blazor\Pages\Links\Links.razor:line 254
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at MudBlazor.MudBaseButton.OnClickHandler(MouseEventArgs ev)
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
FritzTheCat9 commented
fixed for now, using streams on frontend, bigger http client timeout, new .js method to download file
FritzTheCat9 commented
Max downloaded mp3 file:
length - 03:31:45
size - 391 MB
Max downloaded mp4 file:
length - 25:44
size - 973 MB
Not bad so im closing this, in the future test for longer mp4 videos