Hi Thomas,

I don't have access to a REPL at the moment,

what I'd suggest is to use BidiFlow.wrap on your inboundFlow and
outboundFlow, then you put that atop the sslbidiflow, and if/when you need
to short-circuit the  "business end" of the bidiflow you get from the
previous steps, add a join with the identity flow (Flow[Out1, In2]) or use
a Flow.apply with a builder to manually connect the ports.

On Mon, Jul 20, 2015 at 4:36 PM, Thomas Zimmer <[email protected]>
wrote:

> Can you tell me how to setup the correct workflow here?
>
> I would like to have:
>
> incoming data (tcp) -> tls -> logicFlow.in
> logicFlow.out -> tls -> outgoing (tcp)
>
> Cheers and thanks for the help
>
>
>
> On Monday, July 20, 2015 at 3:17:49 PM UTC+2, √ wrote:
>>
>> A Flow is a graph with 1 input and 1 output, you are connecting the
>> bidiflow (2 inputs and 2 outputs) to eachother, leaving no inputs nor
>> outputs open, which means it cannot be a Flow.
>>
>> On Mon, Jul 20, 2015 at 2:58 PM, Thomas Zimmer <[email protected]>
>> wrote:
>>
>>> Hey,
>>>
>>> I really have problems understanding the TLS Bidi-Flows. The specs are
>>> not very helpful as they only do "echo" the input as fas as I understood
>>> and there is not official documentation. What I have so far:
>>>
>>> * A TCP flow (Flow[ByteString, ByteString])
>>> * A logical flow (Flow[ByteString, ByteString])
>>>
>>> How can i connect this to the TLS Bidi-Flow. Here is the code I tried:
>>>
>>> val session = 
>>> NegotiateNewSession.withDefaults.withCipherSuites("TLS_RSA_WITH_AES_128_CBC_SHA")
>>>
>>>   
>>> .withCipherSuites("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256","TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
>>>  
>>> "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384","TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
>>>  "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", 
>>> "TLS_DHE_RSA_WITH_AES_128_CBC_SHA","TLS_RSA_WITH_AES_128_CBC_SHA256","TLS_RSA_WITH_AES_128_CBC_SHA",
>>>  "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA")
>>>   .withProtocols("TLSv1.2")
>>>   .withClientAuth(ClientAuth.None)
>>>
>>>
>>> val closing = IgnoreComplete
>>> val tlsHandler = SslTls(sslContext, session, akka.stream.io.Role.server, 
>>> closing)
>>> val logicalFlow = getLogicalFlow
>>>
>>> // SslTlsInbound to bytes
>>> val inboundFlow: Flow[SslTlsInbound, ByteString, Unit] = 
>>> Flow[SslTlsInbound].map {
>>>   case SessionBytes(_, bytes: ByteString) =>
>>>     log.info("Received bytes")
>>>     bytes
>>>   case SessionTruncated => sys.error("Truncated")
>>> }
>>>
>>> // bytes to SslTlsOutbound
>>> val outboundFlow: Flow[ByteString, SslTlsOutbound, Unit] = 
>>> Flow[ByteString].map {
>>>   case bytes: ByteString =>
>>>     log.info("Sending bytes")
>>>     SendBytes(bytes)
>>> }
>>>
>>> val tlsFlow = Flow() { implicit builder =>
>>>   import FlowGraph.Implicits._
>>>
>>>   val tls = builder.add(tlsHandler)
>>>
>>>   // Define outbound/inbound flows
>>>   tls.out2 ~> inboundFlow ~> tls.in2
>>>   // tls.out1 ~> outboundFlow ~> tls.in1
>>>   tls.in1 <~ outboundFlow <~ tls.out1
>>>
>>>   // Define in/outlet
>>>   (tls.in2, tls.out1)
>>> }
>>>
>>>
>>> // conn = Tcp.IncomingConnection
>>>
>>> conn.handleWith(tlsFlow)
>>>
>>>
>>>
>>> As soon as I start the application I get this error-message:
>>>
>>>
>>> Cannot build Flow with open inputs () and outputs ()
>>> info] akka.actor.ActorInitializationException: exception during creation
>>> info]  at akka.actor.ActorInitializationException$.apply(Actor.scala:166)
>>> info]  at akka.actor.ActorCell.create(ActorCell.scala:596)
>>> info]  at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
>>> info]  at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
>>> info]  at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:263)
>>> info]  at akka.dispatch.Mailbox.run(Mailbox.scala:219)
>>> info]  at 
>>> akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
>>> info]  at 
>>> scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
>>> info]  at 
>>> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
>>> info]  at 
>>> scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
>>> info]  at 
>>> scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
>>> info] Caused by: java.lang.IllegalArgumentException: Cannot build Flow with 
>>> open inputs () and outputs ()
>>> info]  at akka.stream.scaladsl.FlowGraph$Builder.buildFlow(Graph.scala:427)
>>> info]  at akka.stream.scaladsl.FlowApply$class.apply(FlowApply.scala:18)
>>> info]  at akka.stream.scaladsl.Flow$.apply(Flow.scala:313)
>>>
>>>
>>> I do not understand where I should have open inputs or outputs? All the 
>>> BIDI-Flow inputs should be in use?
>>>
>>>  --
>>> >>>>>>>>>> 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.
>>>
>>
>>
>>
>> --
>> Cheers,
>> √
>>
>  --
> >>>>>>>>>> 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.
>



-- 
Cheers,
√

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