Hmm? 
https://github.com/akka/akka/blob/release-2.3-dev/akka-stream/src/main/scala/akka/stream/stage/Stage.scala#L235
 
<https://github.com/akka/akka/blob/release-2.3-dev/akka-stream/src/main/scala/akka/stream/stage/Stage.scala#L235>

> 24 nov 2015 kl. 14:41 skrev Timothy <[email protected]>:
> 
> Hi!
> 
> I've resolved that issue with PushStage:
>   class CloseStage extends PushStage[ByteString, ByteString] {
>     def onPush(elem: ByteString, ctx: Context[ByteString]): SyncDirective =
>       ctx.push(elem)
> 
>     override def onUpstreamFinish(ctx: Context[ByteString]): 
> TerminationDirective = {
>       println("onUpstreamFinish")
>       ???
>     }
>   }
> 
> in my example `onUpstreamFinish` never will be called since `Stage` class 
> doesn't has method `onUpstreamFinish` in an interface to override.
> Thank you and sorry to bother you!
> 
> On Tuesday, November 24, 2015 at 3:53:55 PM UTC+3, Akka Team wrote:
> Hi Timothy,
> 
> 
> Hello hAkkers, It's me again. Is it possible to know when outgoing connection 
> will be closed and then complete closeConn promise or throw failure in flow 
> context? Without closeConn promise I can't work with idle stream.
> This is an example for issue:
> 
> ```
>     val serverAddress = new InetSocketAddress("coreos", 2375)
>     val closeConn = Promise[ByteString]()
>     val source = Source(closeConn.future).drop(1) // as an example. In the 
> real application, source is a WS endless stream of commands from user.
>     Tcp()
>       .outgoingConnection(serverAddress)
>       .runWith(source, Sink.foreach(println))
> ```
> 
> When outgoing connection has been closed then I saw a debug message "Read 
> returned end-of-stream, our side not yet closed". How to avoid this kind of 
> leak?
> 
> This means, that the remote side has closed its connection ("read returned 
> end-of-stream") but the local side still keeps the channel open ("our side 
> not yet closed"). TCP has the concept of half-close and Akka IO reflects that.
> 
>  
> I did try to add StatefulStage to tcp stream and watch on onUpstreamFinish:
> 
> ```
>     class CloseStage extends StatefulStage[ByteString, ByteString] {
>       def initial: State = new State {
>         def onPush(elem: ByteString, ctx: Context[ByteString]): SyncDirective 
> =
>           ctx.push(elem)
> 
>         def onUpstreamFinish(ctx: Context[ByteString]): TerminationDirective 
> = {
>           println("onUpstreamFinish")
>           ???
>         }
>       }
>     }
>     Tcp()
>       .outgoingConnection(serverAddress)
>       .transform(() => new CloseStage())
>       .runWith(source, Sink.foreach(println))
> ```
> 
> But nothing happened.
> 
> In your above example nothing is connected to the input side of the TCP 
> connection, so I don't know if a completion is expected or not. If you have 
> not received an onUpstreamFinish, then the TCP connection has not yet been 
> closed.
>  
> Am I right?
> 
> Unfortunately I don't know, since the above examples are not enough to 
> understand your issue. Can you create a small test case that I can run 
> locally and reproduces your problem?
> 
> -Endre
>  
> 
> Thank you.
> 
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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 <http://googlegroups.com/>.
> To post to this group, send email to akka...@ <>googlegroups.com 
> <http://googlegroups.com/>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> 
> -- 
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com <http://letitcrash.com/>
> Twitter: @akkateam
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/akka-user 
> <http://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Dr. Roland Kuhn
Akka Tech Lead
Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
twitter: @rolandkuhn
 <http://twitter.com/#!/rolandkuhn>

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to