Hi,

Don't use Await inside of a stream as it will block the entire stream from
processing elements, instead use for example mapAsync like this to collect
the complete text messages into strings (note that these will be entirely
in memory so you might want to add some limits in there):

val messageToStringFlow: Flow[Message, String, NotUsed] =
  Flow[Message].mapAsync(1) {
    case TextMessage.Strict(text) =>
      Future.successful(text)
    case streamed: TextMessage.Streamed =>
      streamed.textStream.runFold("")(_ ++ _)
  }

I hope this helps
--
Johan
Akka Team



On Thu, Sep 8, 2016 at 5:59 AM, <[email protected]> wrote:

> Reporting: server side drops connection with timeout in 5 sec (on same
> host):
>
> Code:
>
>       case TextMessage.Streamed(stream)  => {
>         val future = stream.limit(100).runFold("")(_ + _)
>         val txt = Await.result(future, 5 seconds).asInstanceOf[String]
>         process(txt)
>       }
>
> Question:
>
> Does anybody in the world know in practice, how to collect this Source in
> reasonably convenient way?
>
>
>> --
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to