绕过 OCELOT API 网关端点中的端点

发布于 2025-01-17 18:57:23 字数 1456 浏览 4 评论 0原文

我有一个端点正在将最多 200MB 的视频上传到服务器。 每当我尝试同时上传 3 个以上视频时,网关都会抛出 404 错误并显示以下错误消息:

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

如果我增加服务器上的内存,则当用户增加时可能会出现此问题。 那么是否有 UploadVideo 端点可以直接访问网络主机而不通过网关?

我正在使用 Ocelot API 网关。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

情魔剑神 2025-01-24 18:57:23

请阅读有关首先。

从字面上看,问题不足以使用。因此,如果增加内存,则可以缓解它,但是当用户数量较大时,此问题仍然会发生。

如果我们不使用第三方服务,我们可以限制视频的大小,上传的数量,或者同时将限制设置为只有几个上传任务。但这不是最好的解决方案。

在正常情况下,我们仍然考虑使用媒体服务。例如 azure媒体服务。让仅负责Web服务的Web服务器可以更有效地进行站点。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文