BadHttpRequestException: Reading the request body timed out due to data arriving too slowly

I am seeing a few of these exceptions on my API I deployed to a VPS:
MessagePack.MessagePackSerializationException: Error occurred while reading from the stream.
---> Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at MessagePack.MessagePackSerializer.DeserializeAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MessagePack.MessagePackSerializer.DeserializeAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at MessagePack.MessagePackSerializer.DeserializeObjectAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at MessagePack.AspNetCoreMvcFormatter.MessagePackInputFormatter.ReadRequestBodyAsync(InputFormatterContext context)
at DragaliaAPI.Infrastructure.Serialization.MessagePack.CustomMessagePackInputFormatter.ReadRequestBodyAsync(InputFormatterContext context) in /src/DragaliaAPI/DragaliaAPI/Infrastructure/Serialization/MessagePack/InputOutputFormatters.cs:line 52
MessagePack.MessagePackSerializationException: Error occurred while reading from the stream.
---> Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at MessagePack.MessagePackSerializer.DeserializeAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MessagePack.MessagePackSerializer.DeserializeAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at MessagePack.MessagePackSerializer.DeserializeObjectAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at MessagePack.AspNetCoreMvcFormatter.MessagePackInputFormatter.ReadRequestBodyAsync(InputFormatterContext context)
at DragaliaAPI.Infrastructure.Serialization.MessagePack.CustomMessagePackInputFormatter.ReadRequestBodyAsync(InputFormatterContext context) in /src/DragaliaAPI/DragaliaAPI/Infrastructure/Serialization/MessagePack/InputOutputFormatters.cs:line 52
I could just shrug it off as the user on the other end of the request having a poor internet connection, but it happened three times last night to two different people, so I’d at least like to briefly investigate - does anyone have any ideas what debugging steps I could take? There isn't anything from around this time period in the reverse proxy logs
3 Replies
OlujA
OlujA3d ago
in appsettings.json, add this;
{
"Logging": {
"LogLevel": {
"Microsoft.AspNetCore.Server.Kestrel": "Debug",
"Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets": "Debug"
}
}
}
{
"Logging": {
"LogLevel": {
"Microsoft.AspNetCore.Server.Kestrel": "Debug",
"Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets": "Debug"
}
}
}
then check "Request body" in the logs. you might re-produce the error locally, post to URL with limit-rate 1K(or w/e)
dreadfullydistinct
I can probably reproduce it by throttling my connection but what I’d like to know is whether I can rule out my infrastructure as the cause I guess there’s always going to be people with poor connections using my thing so it’s probably unavoidable in the long term
OlujA
OlujA3d ago
yea obv, but raising datarate limit won't hurt(at least test it for a while)

Did you find this page helpful?