Utf8Json
Utf8Json copied to clipboard
KestrelBadHttpRequestException from JsonSerializer.DeserializeAsync
We are using Utf8Json library in our application. From the below line we are seeing weird exception being thrown which we cannot figure out why it is happening?
From this below line -
containerRequest = await JsonSerializer.DeserializeAsync<Request>(context.Request.Body, StandardResolver.ExcludeNullCamelCase);
We are seeing the exception as -
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelBadHttpRequestException.Throw(RequestRejectionReason reason)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
at Utf8Json.JsonSerializer.DeserializeAsync[T](Stream stream, IJsonFormatterResolver resolver)
at Goldy.Api.Kestrel.Middleware.ContainerMiddleware.HandleRequest(HttpContext context, ILoggingService loggingService, LoggingContext loggingContext, Action`1 setRootSpanMessage) in /app/Goldy/Api/Kestrel/Middleware/ContainerMiddleware.cs:line 66
at Goldy.Api.Kestrel.Middleware.BaseMiddleware.Invoke(HttpContext context) in /app/Goldy/Api/Kestrel/Middleware/BaseMiddleware.cs:line 90
I am confuse why this is happening? Is there anything wrong in our application that can cause these type of error messages to pop up?