我有在IIS上托管的dotnetcore 2.2.2 Web API应用程序。有一个用于与该api进行交互的有角度的客户端。
非常间歇地,我们遇到文件上传不起作用的问题,奇怪的是我无法在我的PC上复制它,但可以在其他2个上复制它。我们的日志中的错误是。
Microsoft.AspNetCore.Connections.ConnectionResetException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.<GetResult>g__ThrowSocketException|7_0(SocketError e)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.ProcessReceives()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive()
我无法找到可能导致这种情况的原因,但我想知道茶k内部是否存在可能导致这种情况的错误?
某些配置包括:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureKestrel(options =>
{
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(5);
options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 80, gracePeriod: TimeSpan.FromSeconds(20));
options.Limits.MinResponseDataRate = new MinDataRate(bytesPerSecond: 80, gracePeriod: TimeSpan.FromSeconds(20));
})
.ConfigureAppConfiguration((hostContext, config) =>
{
// delete all default configuration providers
config.Sources.Clear();
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
config.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true);
}).Build();
我不确定还有什么要提供的信息,因为直到请求进入控制器本身似乎都没有记录。但是接收到请求的控制器将Stream
作为其媒体参数。因此,在这种情况下,我不使用IFormFile,而是要接收的代码基于microsofts site