It looks correct to me, what is it that makes you think it is not the server closing the connection as the exception says?
-- Johan Akka Team On Thu, Jan 26, 2017 at 3:20 PM, Maksym Besida <maks.bes...@gmail.com> wrote: > Based on this paragraph > <http://doc.akka.io/docs/akka/2.4.16/scala/stream/stream-cookbook.html#Balancing_jobs_to_a_fixed_pool_of_workers> > I've > implemented a balancer for tcp outgoing requests. > > def outGoing(host: String, port: Int) = > Tcp().outgoingConnection(InetSocketAddress.createUnresolved(host, port), > halfClose = true) > > > def balancer(endpoints: Seq[(String, Int)]): Flow[ByteString, ByteString, > NotUsed] = { > Flow.fromGraph(GraphDSL.create(){ implicit b => > import GraphDSL.Implicits._ > val balancer = b.add(Balance[ByteString](endpoints.length, > waitForAllDownstreams = true)) > val merge = b.add(Merge[ByteString](endpoints.length)) > > endpoints.foreach { case(host, port) => > balancer ~> outGoing(host, port).async ~> merge > } > > FlowShape(balancer.in, merge.out) > }) > } > > > I use it as follows > > source.via(balancer(Seq(("localhost", 22002), ("localhost", > 22002)))).runWith(Sink.ignore) > > > I'm not interseted in result so I run it with Sink.ignore. I open 2 tcp > connections to the same destination host for the test purpose(in reality it > will go to different hosts) > > When I produce a lot of elments in my source I eventually(not after first > message) get next error and stream fails > akka.stream.StreamTcpException: The connection closed with error: An > existing connection was forcibly closed by the remote host > > Can anybody suggest what is wrong with the example? > > -- > >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.