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



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