akka http throws EntityStreamException: Entity stream truncation
<p>I'm writing a client for a rest API using the akka http library. The library seems very powerful, but it works very unstable for me. Quite often (not always) it throws the following exception when I try to consume an HttpResponse.entity:</p>

<blockquote>
  <p>EntityStreamException: Entity stream truncation</p>
</blockquote>

<p>and after this it stops processing subsequent requests at all. Maybe it tries to deal with some back-pressure or actors just die, I don't know.</p>

<p>It doesn't matter how I send a request, using the Request-Level Client-Side API:</p>

<pre><code>def pollSearchResult(searchId: String): FutureActionResult[String, SearchResult] = {
    val request = HttpRequest(GET, s"http://***/Search/$searchId")

    for {
      response &lt;- Http().singleRequest(request)
      entity &lt;- Unmarshal(response.entity).to[String]
      result = entity.decodeEither[SearchResult]
    } yield result
  }
</code></pre>

<p>or using the Connection-Level Client-Side API:</p>

<pre><code>val client = Http(actorSystem).outgoingConnection("***")

def pollSearchResult(searchId: String): FutureActionResult[String, SearchResult] = {
    val request = HttpRequest(GET, s"Search/$searchId")

    for {
      response &lt;- Source.single(request).via(client).runWith(Sink.head)
      entity &lt;- Unmarshal(response.entity).to[String]
      result = entity.decodeEither[SearchResult]
      } yield result
    }
</code></pre>

<p>It doesn't metter whether I consume the entity using unmarshaller or manually using the getDataBytes, the result is the same - the above exception.</p>

<p>The http status of the response is 200 OK, headers are ok, it is a "Default" entity (so, no chunking), content length is about 500-2000 Kb (increasing akka.http.parsing.max-content-length doesn't help, although the default value should be enough). The server is also ok - other http libraries on other platforms work with this API just fine.</p>

<p>Is it a bug or I am doing something wrong? What is the best non blocking, asycnhonous http library for scala?</p>