Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

KestrelBadHttpRequestException from JsonSerializer.DeserializeAsync #252

Open
TechGeeky opened this issue Sep 3, 2021 · 0 comments
Open

Comments

@TechGeeky
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant