If I parse your answer properly, and it does mean that when the LB does its
pingy connect thing, then it *does not send anything*, meanwhile a client
always sends an initial message, then the simple answer is to use the
".initialTimeout" operator.

There are basic 4 timeout related operators:
 - initialTimeout: timeout only on the first element
 - completionTimeout: upper bound for the stream to finish
 - idleTimeout: timeout on idle (this has a Bidi version which takes both
directions into account)
 - idleInject: basic hearbeating/keepalive operator

If none of this cover what you want, then (and only then) you should build
your own GraphStage. Here are the implementations of the stages above, you
can use them as a template for your own:
https://github.com/akka/akka/blob/master/akka-stream/src/main/scala/akka/stream/impl/Timers.scala

-Endre

On Thu, Feb 11, 2016 at 5:04 PM, Thomas Zimmer <[email protected]>
wrote:

> Ah sorry for not making a clear statement here. So the LB makes connection
> from time to time which DO NOT send the Proxy String. Only when a "real"
> client makes its connection via the LB the PROXY is send out. So what is
> the best thinkable solution you would recommend me?
>
> Thanks for helping me btw :)
>
> On Thursday, February 11, 2016 at 4:52:52 PM UTC+1, drewhk wrote:
>>
>> I don't understand this answer fully :(  Does the client only or also the
>> balancer send this first message? Or reformulated, is there any
>> distinguishing factor between the client and balancer connection?
>>
>> -Endre
>>
>> On Thu, Feb 11, 2016 at 4:45 PM, Thomas Zimmer <[email protected]>
>> wrote:
>>
>>> Excatly. I use the PROXY Protocol which only sends a string "PROXY IP IP
>>> port port\r\n" right in the beginning. So can you think of any good
>>> solution?
>>>
>>> On Thursday, February 11, 2016 at 4:43:08 PM UTC+1, drewhk wrote:
>>>
>>>>
>>>>
>>>> On Thu, Feb 11, 2016 at 4:24 PM, Thomas Zimmer <[email protected]>
>>>> wrote:
>>>>
>>>>> 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.
>>>>>
>>>>
>>>> I don't see how can this be solved (with any framework). How would you
>>>> distinguish why there is an idle connection if both your load balancer or
>>>> client can be completely silent?
>>>>
>>>> The only way to solve this if an idle client sends at least one message
>>>> in the beginning, while the balancer does not. Then you can use
>>>> .initialTimeout to distinguish between the two.
>>>>
>>>> Endre
>>>>
>>>>
>>>>> 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 <[email protected]
>>>>>> > 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 [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.
>>>>>
>>>>
>>>> --
>>> >>>>>>>>>> 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.
>

-- 
>>>>>>>>>>      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