Thank you for your answer. 

But If I use onCompleteSink after connection flow, future will not be 
completed successfully however data will be downloaded by client. If client 
is failed while downloading there are still no exceptions on server side. 
 Could you provide me some links from documentation about exception 
handling in StreamTcp? Do I need onCompleteSink in my case at all?

updateSource ~> connection.flow ~> OnCompleteSink[ByteString]  


вторник, 7 апреля 2015 г., 14:16:13 UTC+3 пользователь Akka Team написал:
>
> Hi,
>
> The connection flow will publish the errors, but you feed them to a 
> BackholeSink. Also, your OnCompleteSink is probably at the wrong place -- 
> it will not tell you anything about whether the TCP connection have sent 
> everything fine or not. As such, you will close the binding before you have 
> sent everything through TCP.
>
> -Endre
>
> On Mon, Apr 6, 2015 at 3:23 PM, zergood <zergoo...@gmail.com <javascript:>
> > wrote:
>
>> Hello!
>>
>> My server side:
>>
>>   def update: Iterator[ByteString]  
>>
>>   lazy val binding = StreamTcp(system).bind(address, idleTimeout = 
>> 20.seconds)
>>
>>   def start(): Future[Unit] = {
>>     val firstCompleted = Promise[Unit]()
>>     val foreachConnection = ForeachSink[IncomingConnection] {
>>       connection =>
>>         val handleConnection = FlowGraph { implicit b =>
>>           import akka.stream.scaladsl.FlowGraphImplicits._
>>           val updateSource = Source[ByteString](() => update)
>>           val broadcast = Broadcast[ByteString]
>>
>>           updateSource ~> broadcast
>>           broadcast ~> connection.flow ~> BlackholeSink
>>           broadcast ~> OnCompleteSink[ByteString] { res =>
>>             firstCompleted.complete(res)
>>           }
>>         }
>>
>>          handleConnection.run()
>>     }
>>
>>
>>     val connectionsMap = binding.connections.to(foreachConnection).run()
>>     firstCompleted.future.flatMap {_ => binding.unbind(connectionsMap)}
>>       .recoverWith { case ex => binding.unbind(connectionsMap).flatMap(_ 
>> => {
>>       Future.failed(ex)
>>     })}
>>   }
>>
>>
>> If i have exception on the client side, this future will be completed 
>> with Success anyway. Is there a way to handle tcp exceptions (client 
>> disconect for example) ? 
>>
>> -- 
>> >>>>>>>>>> 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+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> 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.

Reply via email to