FormData请求具有响应正文超时

时间:2018-11-06 14:03:48

标签: .net node.js multipartform-data

我正在Node.Js中编写一个测试,该测试在.NET Core后端服务上执行FormData请求。我使用NPM软件包form-data创建一个FormData实例,然后使用node-fetch来执行实际请求。

我的请求包含一个我想发送到服务器的文本文件:

const path = "c:/path/to/my/file.txt";
const file = { fileName: path.basename(path), data: fs.createReadStream(path) };
content.append("file", file.data, file.fileName);

服务器响应一个非常奇怪的错误,我从未见过:

Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate.

BadHttpRequestException
   at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason)
      at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.PumpAsync()
      at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
      at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
      at System.IO.Pipelines.Pipe.GetReadAsyncResult()
      at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.WebUtilities.BufferedReadStream.EnsureBufferedAsync(Int32 minCount, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
      at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
      at Microsoft.AspNetCore.Mvc.ModelBinding.FormValueProviderFactory.AddValueProviderAsync(ValueProviderFactoryContext context)
      at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ActionContext actionContext, IList`1 factories)
      at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ControllerContext controllerContext)
      at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
      at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
      at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()

系统正在本地运行,我已经检查了网络连接,服务器可访问并且其他操作都可以正常工作。请求似乎也有效body属性中有数据。

enter image description here

我承认我对FormData不太了解,所以也许我对请求一无所知。

感谢您的帮助!

0 个答案:

没有答案