Empty body with async-http-client
See original GitHub issueAfter upgrading to 0.21.2
I am seeing a lot of empty body errors while using async-http-client as the client backend.
Caused by: org.http4s.MalformedMessageBodyFailure: Malformed message body: Invalid JSON: empty body
at org.http4s.jawn.JawnInstances$.defaultJawnEmptyBodyMessage(JawnInstances.scala:42)
at org.http4s.jawn.JawnInstances.jawnEmptyBodyMessage(JawnInstances.scala:17)
at org.http4s.jawn.JawnInstances.jawnEmptyBodyMessage$(JawnInstances.scala:16)
at org.http4s.circe.package$.jawnEmptyBodyMessage(package.scala:3)
at org.http4s.circe.CirceInstances.$anonfun$jsonDecoderByteBufferImpl$1(CirceInstances.scala:41)
at scala.util.Either.flatMap(Either.scala:352)
at cats.data.EitherT.$anonfun$subflatMap$1(EitherT.scala:365)
at scala.Function1.$anonfun$andThen$1(Function1.scala:85)
at cats.effect.IO$Map.apply(IO.scala:1504)
at cats.effect.IO$Map.apply(IO.scala:1502)
at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:142)
I suspect that something in #3261 causes the body to be emptied before it is read in some cases?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:16 (14 by maintainers)
Top Results From Across the Web
Getting response out of AsyncHttpClient - java - Stack Overflow
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on...
Read more >AsyncHttpClient (Asynchronous Http Client 2.10.0 API)
You can asynchronously process the response status, headers and body and decide when to stop processing the response by returning a new AsyncHandler.State.ABORT ......
Read more >std/httpclient
This module implements a simple HTTP client that can be used to retrieve webpages and other data. Retrieving a website. This example uses...
Read more >org.asynchttpclient.Response Java Examples
This page shows Java code examples of org.asynchttpclient.Response. ... private void twit(DashBoard dash, String body) { if (Twitter.
Read more >How to use the tornado.httpclient.AsyncHTTPClient function in ...
Return(ret) # load response and handle return errors, if any response = json.loads(http_response.body) if not 'result' in response: Log.error("Empty ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to add. We’ve been seeing this for a couple of weeks in three separate Microservices. I only just tracked it down today to being this issue. AsyncHttpClients in services that are absolutely fine running at scale on
0.21.1
start to return intermittent empty body responses on0.21.2
.@kevinmeredith I don’t have a test that reliably reproduces this, though existing tests in the http4s suite are failing intermittently due to the problem.
Here’s an example of a scenario that would trigger the problem
onStream
is calledonStream
is forked and started,onStream
completes becauserunAsync
onCompleted
is called prior to the async callback from (3) completing, which completes the callback with response having an empty bodyit comes down to whether the forked callback from (3) runs before
onCompleted
is called.