It turns out that the problem was something different.

The server was producing chunks with a size of more than the default
value for max-chunk-size (1m). The client aborted with
Failure(akka.http.model.EntityStreamException: HTTP chunk size exceeds
the configured limit of 1048576 bytes). I did not see the failure
because I was using Sink.ignore. Now that I switched to
Sink.onComplete as suggested, the problem was obvious.

Adding an application.conf that increases the chunk size to 8m (
akka.http.client.parsing.max-chunk-size = 8m) fixed the issue.

Is there anything else to consider when increasing the chunk size?

On Tue, Apr 7, 2015 at 11:35 PM, Rüdiger Klaehn <rkla...@gmail.com> wrote:
> Thanks a lot. Seems quite obvious now that you explained it.
>
> On Tue, Apr 7, 2015 at 12:25 PM, Akka Team <akka.offic...@gmail.com> wrote:
>> Hi Rüdiger,
>>
>> You are waiting on the finishFuture of the foreach, but not waiting on the
>> internal stream you materialize inside foreach. The finishFuture will
>> complete as soon as .run() has been called on the internal stream, which is
>> probably earlier than the completion of that internal stream itself. You can
>> change that internal stream to use a Sink.onComplete which will return a
>> Future, and then you can change the enclosing foreach to a mapAsync, so that
>> the final Future completes only after the internal stream completes.
>>
>> -Endre
>>
>> On Wed, Apr 1, 2015 at 10:18 AM, rklaehn <rkla...@gmail.com> wrote:
>>>
>>> Hi all,
>>>
>>> I am trying to consume a chunked http stream from the client side. The
>>> code is basically identical to the gist
>>> https://gist.github.com/rklaehn/3f26c3f80e5870831f52#file-client-example
>>>
>>> ```scala
>>>   val printChunksConsumer = Sink.foreach[HttpResponse] { res =>
>>>     if(res.status == StatusCodes.OK) {
>>>       println("Got 200!")
>>>       if(res.entity.isChunked)
>>>         println("Chunky!")
>>>       res.entity.dataBytes.map { chunk =>
>>>         System.out.write(chunk.toArray)
>>>         System.out.flush()
>>>       }.to(Sink.ignore).run()
>>>     } else
>>>       println(res.status)
>>>   }
>>> ```
>>>
>>> However, it seems that this still does not work. When I do a request that
>>> produces a very long chunked response, the map never gets executed. I tried
>>> various ways of accessing the chunks: matching on the entity and mapping the
>>> chunks, dataBytes, getDataBytes. Nothing seems to make a difference. The
>>> server side is definitely working. At least it works like a charm when using
>>> curl.
>>>
>>> This is using akka-http 1.0-M5.
>>>
>>> Any ideas?
>>>
>>> Rüdiger
>>>
>>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ:
>>> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to akka-user+unsubscr...@googlegroups.com.
>>> To post to this group, send email to akka-user@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> Akka Team
>> Typesafe - Reactive apps on the JVM
>> Blog: letitcrash.com
>> Twitter: @akkateam
>>
>> --
>>>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>>>> Check the FAQ:
>>>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to