Thanks Endre,
Helpers or a couple of lines in the Akka documentation. Which BTW is a
great resource.
-chhil

On Fri, Aug 19, 2016, 4:47 PM Akka Team <akka.offic...@gmail.com> wrote:

> Hi,
>
> On Fri, Aug 19, 2016 at 12:41 PM, murtuza chhil <chil...@gmail.com> wrote:
>
>> Thank you for the pointer.
>>
>> Changed it to the following
>> ```java
>>  final List<Inet.SocketOption> options = new
>> ArrayList<Inet.SocketOption>();
>>         Source<IncomingConnection, CompletionStage<ServerBinding>>
>> serverSource = Tcp
>>
>> .get(system).bind("127.0.0.1",6000,100,options,true,Duration.create(5,
>> TimeUnit.MINUTES));
>> ```
>> Now I get the data.
>>
>>
>> I was mimicking this scala code
>> <https://github.com/adamw/reactive-akka-pres/blob/master/src/main/scala/com/softwaremill/reactive/step1/ReceiverStep1.scala>
>>  after
>> watching Adams youtube video.
>> Does the scala implementation get away by not defining the halfclose
>> option or its done behind the scenes or its an older version of akka that
>> allows it?
>>
>
> I have no clue why he gets away with it, it is racy.
>
> I guess we should provide some helpers for the case when one only wants to
> read from TCP and close the output when the other side closes.
>
> -Endre
>
>
>>
>> -chhil
>>
>> On Friday, August 19, 2016 at 2:54:36 PM UTC+5:30, Akka Team wrote:
>>>
>>>
>>>
>>> On Sun, Aug 14, 2016 at 2:18 PM, murtuza chhil <chi...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I have a simple client that reads a csv file and send it across. When I
>>>> have a netcat server I can see the data come through.
>>>>
>>>> However when I have a Akka stream based server I do see the connection
>>>> but I don't see the data come through.
>>>>
>>>> Could someone be kind enough to let me know where I have screwed up?
>>>>
>>>> Server code
>>>>
>>>>
>>>>         ActorSystem system = ActorSystem.create("System");
>>>>         ActorMaterializer mat = ActorMaterializer.create(system);
>>>>
>>>>         Source<IncomingConnection, CompletionStage<ServerBinding>> 
>>>> serverSource = Tcp
>>>>                 .get(system).bind("127.0.0.1", 6000);
>>>>         serverSource.runForeach(
>>>>                 conn -> {
>>>>                     System.out.println(conn.remoteAddress());
>>>>                     Sink<ByteString, NotUsed> receiveSink = conn
>>>>                             .flow()
>>>>                             .via(Framing.delimiter(
>>>>                                     ByteString.fromString("\r\n"), 100000))
>>>>                             .to(Sink.foreach(str -> {
>>>>                                 System.out.println("< " + str);
>>>>                                 // Thread.sleep(10);
>>>>                             }));
>>>>                     Source<ByteString, NotUsed> emptySource = 
>>>> Source.empty();
>>>>                     emptySource.to(receiveSink).run(mat);
>>>>
>>>> Since you run with an emptySource, the connection will be closed,
>>> because you just completed the output side of your TCP connection (because
>>> of the emptySource) and you have halfClose = false in your bind command
>>> (the default).
>>>
>>>
>>>>
>>>>
>>>>                 }, mat);
>>>>
>>>> ​
>>>>
>>>>
>>>> Client code : Reads a file, prints it line by and sends it over the
>>>> socket. The connecting and sending part works as I can see the data
>>>> received at a netcat server.
>>>>
>>>>         ActorSystem system = ActorSystem.create("client");
>>>>         ActorMaterializer mat = ActorMaterializer.create(system);
>>>>
>>>>         Flow<ByteString, ByteString, CompletionStage<OutgoingConnection>> 
>>>> serverConnection = Tcp
>>>>                 .get(system).outgoingConnection("127.0.0.1", 6000);
>>>>         Path file = Paths.get("C:\\temp\\Generic.csv");
>>>>         CompletionStage<IOResult> cs = FileIO.fromPath(file)
>>>>
>>>>         .via(Framing.delimiter(ByteString.fromString("\r\n"), 100000))
>>>>                 .map(str -> {
>>>>                     System.out.println(str.utf8String());
>>>>                     return str.concat(ByteString.fromString("\r\n"));
>>>>                 })
>>>>
>>>>                 
>>>> .via(serverConnection).to(akka.stream.javadsl.Sink.ignore())
>>>>                 .run(mat);
>>>>
>>>> ​
>>>> -chhil
>>>>
>>>> --
>>>> >>>>>>>>>> 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+...@googlegroups.com.
>>>> To post to this group, send email to akka...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/akka-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> Akka Team
>>> Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM
>>> 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 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.
>>
>
>
>
> --
> Akka Team
> Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM
> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/hPb96duYgpc/unsubscribe.
> To unsubscribe from this group and all its topics, 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.

Reply via email to