Would it be possible to set a completion timeout depending on some kind of 
"state"? Like in my case I have a setup that I have a running Akka 
Application with a Loadbalancer in front. The Loadblancer open a TCP 
Connection every 10 seconds (Think its their health-check). Now when I 
don't receive any with 10 seconds I would like to terminate that connection 
to save resources. The IDLE TImeout would help me here BUT it would be 
problematic with "active" client that do not transmit any data within that 
timeframe. Theoretically I could set this value to a high number but than I 
still have these open TCP Connections for that period. How could I solve 
this puzzle? 

On Thursday, February 11, 2016 at 3:46:29 PM UTC+1, drewhk wrote:
>
> Hi,
>
> Just use the idleTimeout, or completionTimeout combinator (or both).
>
> It shouldn't have worked with 1.X versions btw, and I think it did not in 
> more recent versions.
>
> -Endre
>
> On Thu, Feb 11, 2016 at 3:36 PM, Thomas Zimmer <t.zi...@eslgaming.com 
> <javascript:>> wrote:
>
>> Hello,
>>
>> I was playing around with Stream API 2.0 where I got a strange 
>> error-message: 
>>
>> "Cannot materialize an incoming connection Flow twice.". I could track 
>> down the issue to a code-line. So this what I am doing
>>
>> Server code:
>>
>> val connections = Tcp().bind(localHost.getHostName, port, backlog, 
>> socketOptions, idleTimeout = 10.seconds)
>>
>> connections.runForeach(handleConnnection(_))
>>
>>
>> where the handleConnection function spawns an Actor which setups a flow 
>> like this:
>>
>> conn.handleWith(getLogicalFlow())
>>
>>
>> Now I set some kind of timer that should close the connection (To prevent 
>> long open TCP Connections that I for example got from a Loadbalancer I put 
>> in front of my Server application). I did this with Akka Streaming 1.X like 
>> this: 
>>
>> def closeConnection(connection: Tcp.IncomingConnection): Unit = {
>>   implicit val materializer = ActorMaterializer()
>>   // Handle connection with the closing Flow
>>   connection.flow.runWith(Source.empty, Sink.cancelled)
>> }
>>
>> I also tried: 
>>
>> connection.handleWith(Flow.fromSinkAndSource(Sink.cancelled, Source.empty))
>>
>>
>>
>> But the problem seems like that I cannot change the flow as soon as it 
>> materialized. Any good thoughts on how I could fix this?
>>
>> Regards,
>> Thomas
>>
>> -- 
>> >>>>>>>>>> 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 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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