question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty body with async-http-client

See original GitHub issue

After 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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
caoiltecommented, Apr 7, 2020

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 on 0.21.2.

1reaction
wemrysicommented, Apr 19, 2020

@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

  1. An HTTP message with a small entity body is received.
  2. onStream is called
  3. The callback invocation in onStream is forked and started, onStream completes because runAsync
  4. async-http-client processes the entity body
  5. onCompleted is called prior to the async callback from (3) completing, which completes the callback with response having an empty body
  6. The async callback from (3) completes, having no effect because of (5)

it comes down to whether the forked callback from (3) runs before onCompleted is called.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found