简体   繁体   中英

Bypass endpoint in OCELOT API gateway endpoint

I have one endpoint which is uploading upto 200MB videos to the server. Whenever I try to upload more than 3 videos simultaneously, gateway is thowing 404 error with below error message:

warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
  requestId: 0HMFL2SCVRST5:00000001, previousRequestId: no previous request id, message: Error Code: UnmappableRequestError Message: Error when parsing incoming request, exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
     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 where exception was thrown ---
     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.CopyToAsyncInternal(Stream destination, CancellationToken cancellationToken)
     at Ocelot.Request.Mapper.RequestMapper.ToByteArray(Stream stream)
     at Ocelot.Request.Mapper.RequestMapper.MapContent(HttpRequest request)
     at Ocelot.Request.Mapper.RequestMapper.Map(HttpRequest request, DownstreamRoute downstreamRoute) errors found in ResponderMiddleware. Setting error response for request path:/v1/Video/UploadVideo, request method: POST

If I increase memory on the server this issue may come up when users increased. So is there anyway UploadVideo endpoint to be directly hitting the webhost and not go through the gateway?

I am using the Ocelot API gateway.

Please read this official doc about OutOfMemoryException Class first.

The problem is literally, that the memory is not enough to use. So if you increase the memory, it can be alleviated, but when the number of users is large, this problem will still occur.

If we don't use third-party services, we can limit the size of the video, the number of uploads, or set a limit to only a few upload tasks at the same time. But this is not the best solution.

Under normal circumstances, we still consider using media services. Such as Azure Media Service . Let the web server, only responsible for web services, can conduct sites more efficiently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM