These are chat archives for akkadotnet/AkkaStreams

Jan 2018
Matthias Berndt
Jan 18 2018 00:54
Hey, I'm trying to write a TCP server with Akka Streams. So I used Tcp.bind(…).to(Source.foreach(handleConnection)).run, so far, so good.
handleConnection is of type IncomingConnection => Unit, and it basically just does connection.handleWith(Flow.fromSinkAndSource(mySink, Source.empty))
that's because I only want to receive stuff from the connection and process it, I never want to send anything
Unfortunately, it doesn't seem to be possible to use Source.empty, because then when I try and send anything to the socket, I immediately get "connection reset"
If I just send some junk, like Source.repeat(ByteString("a")) everything works just fine, but that's hardly a solution I'd say :-)
Matthias Berndt
Jan 18 2018 01:14
OK, I've made it work using connection.handleFlow(Flow[ByteString].alsoTo(mySink).filter(_ => false)
But that feels really dumb, I'm sure there's a nicer way