Hi Endre, Thank you so much for prompt reply.
As I see this in the SslTls API doc: The TLS specification does not permit half-closing of the user data session > that it transports—to be precise a half-close will always promptly lead to > a full close. This means that canceling the plaintext output or completing > the plaintext input of the SslTls stage will lead to full termination of > the secure connection without regard to whether bytes are remaining to be > sent or received, respectively. Especially for a client the common idiom of > attaching a finite Source to the plaintext input and transforming the > plaintext response bytes coming out will not work out of the box due to > early termination of the connection. For this reason there is a parameter > that determines whether the SslTls stage shall ignore completion and/or > cancellation events, and the default is to ignore completion (in view of > the client–server scenario). In order to terminate the connection the > client will then need to cancel the plaintext output as soon as all > expected bytes have been received. When ignoring both types of events the > stage will shut down once both events have been received. See also Closing > <http://doc.akka.io/api/akka-stream-and-http-experimental/1.0/akka/stream/io/Closing.html> > . I will make it like this: - Set halfClose = false on the Tcp outgoing connection - Keep the default closing == IgnoreComplete on the SslTls - When I want to close it, call cancel() on ActorSubscriber (my reader) Will this work? Thanks On Thursday, September 10, 2015 at 12:58:41 PM UTC+8, Chongkai Jiang wrote: > > Sorry I know this is rather silly question, but I have to jump to Akka > streams before I completely understand everything, because I need its TLS > support to do async IO, to implement an async Thrift client. > > val sslContext = ... > val tls = SslTls(sslContext, NegotiateNewSession(None, None, None, None), > Client) > val transport = Tcp()(system).outgoingConnection(ip, port) > val flow = tls.join(transport) > Source(ActorPublisher[SslTlsOutbound](writer)).via(flow).runWith(Sink( > ActorSubscriber[SslTlsInbound](reader))) > > reader and writer are two actors: reader gets ByteString and translates to > Thrift responses and deliver them to application; write translates Thrift > requests to ByteString and send out. > > It seems to work well. But how to make it stop, being sure the TCP connection > has been closed? > > > Thanks for your help! > > -- >>>>>>>>>> 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.
