Re: [akka-user] Basic Akka stream server not receiving data sent by client

2016-08-19 Thread chhil
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  wrote:

> Hi,
>
> On Fri, Aug 19, 2016 at 12:41 PM, murtuza chhil  wrote:
>
>> Thank you for the pointer.
>>
>> Changed it to the following
>> ```java
>>  final List options = new
>> ArrayList();
>> Source
>> 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
>> 
>>  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  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 
 serverSource = Tcp
 .get(system).bind("127.0.0.1", 6000);
 serverSource.runForeach(
 conn -> {
 System.out.println(conn.remoteAddress());
 Sink receiveSink = conn
 .flow()
 .via(Framing.delimiter(
 ByteString.fromString("\r\n"), 10))
 .to(Sink.foreach(str -> {
 System.out.println("< " + str);
 // Thread.sleep(10);
 }));
 Source 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 
 serverConnection = Tcp
 .get(system).outgoingConnection("127.0.0.1", 6000);
 Path file = Paths.get("C:\\temp\\Generic.csv");
 CompletionStage cs = FileIO.fromPath(file)

 .via(Framing.delimiter(ByteString.fromString("\r\n"), 10))
 .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  - Reactive apps on the JVM
>>> Twitter: @akkateam
>>>
>> --
>> >> Read the 

Re: [akka-user] Basic Akka stream server not receiving data sent by client

2016-08-19 Thread Akka Team
Hi,

On Fri, Aug 19, 2016 at 12:41 PM, murtuza chhil  wrote:

> Thank you for the pointer.
>
> Changed it to the following
> ```java
>  final List options = new ArrayList()
> ;
> Source
> 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
> 
>  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  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 
>>> serverSource = Tcp
>>> .get(system).bind("127.0.0.1", 6000);
>>> serverSource.runForeach(
>>> conn -> {
>>> System.out.println(conn.remoteAddress());
>>> Sink receiveSink = conn
>>> .flow()
>>> .via(Framing.delimiter(
>>> ByteString.fromString("\r\n"), 10))
>>> .to(Sink.foreach(str -> {
>>> System.out.println("< " + str);
>>> // Thread.sleep(10);
>>> }));
>>> Source 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 
>>> serverConnection = Tcp
>>> .get(system).outgoingConnection("127.0.0.1", 6000);
>>> Path file = Paths.get("C:\\temp\\Generic.csv");
>>> CompletionStage cs = FileIO.fromPath(file)
>>>
>>> .via(Framing.delimiter(ByteString.fromString("\r\n"), 10))
>>> .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/c
>>> urrent/additional/faq.html
>>> >> Search the archives: https://groups.google.com/grou
>>> p/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  - 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 

Re: [akka-user] Basic Akka stream server not receiving data sent by client

2016-08-19 Thread murtuza chhil
Thank you for the pointer.

Changed it to the following
```java
 final List options = new ArrayList();
Source 
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 

 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?

-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  > 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 
>> serverSource = Tcp
>> .get(system).bind("127.0.0.1", 6000);
>> serverSource.runForeach(
>> conn -> {
>> System.out.println(conn.remoteAddress());
>> Sink receiveSink = conn
>> .flow()
>> .via(Framing.delimiter(
>> ByteString.fromString("\r\n"), 10))
>> .to(Sink.foreach(str -> {
>> System.out.println("< " + str);
>> // Thread.sleep(10);
>> }));
>> Source 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 
>> serverConnection = Tcp
>> .get(system).outgoingConnection("127.0.0.1", 6000);
>> Path file = Paths.get("C:\\temp\\Generic.csv");
>> CompletionStage cs = FileIO.fromPath(file)
>>
>> .via(Framing.delimiter(ByteString.fromString("\r\n"), 10))
>> .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  - 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.


Re: [akka-user] Basic Akka stream server not receiving data sent by client

2016-08-19 Thread Akka Team
On Sun, Aug 14, 2016 at 2:18 PM, murtuza chhil  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 
> serverSource = Tcp
> .get(system).bind("127.0.0.1", 6000);
> serverSource.runForeach(
> conn -> {
> System.out.println(conn.remoteAddress());
> Sink receiveSink = conn
> .flow()
> .via(Framing.delimiter(
> ByteString.fromString("\r\n"), 10))
> .to(Sink.foreach(str -> {
> System.out.println("< " + str);
> // Thread.sleep(10);
> }));
> Source 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 
> serverConnection = Tcp
> .get(system).outgoingConnection("127.0.0.1", 6000);
> Path file = Paths.get("C:\\temp\\Generic.csv");
> CompletionStage cs = FileIO.fromPath(file)
>
> .via(Framing.delimiter(ByteString.fromString("\r\n"), 10))
> .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+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  - 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.