[akka-user] [akka-stream] tcp retransmission?

2016-02-28 Thread Val P
I am trying to understand why I'm seeing TCP retransmissions on a simple 
program. I created a small program based on the 2.4.2 docs:


object HelloWorld {
  def main(args: Array[String]): Unit = {
implicit val system = ActorSystem("Sys")
implicit val materializer = ActorMaterializer()

val connections: Source[IncomingConnection, Future[Tcp.ServerBinding]] =  
Tcp().bind("localhost", )
connections runForeach { connection =>
  // server logic, parses incoming commands
  val commandParser = Flow[String].takeWhile(_ != "BYE").map(_ + "!")

  import connection._
  val welcomeMsg = s"Welcome to: $localAddress, you are: $remoteAddress!"
  val welcome = Source.single(welcomeMsg)


  val serverLogic = Flow[ByteString]
.via(Framing.delimiter( ByteString("\n"),  256 ))
.map(_.utf8String)
.via(commandParser)
// merge in the initial banner after parser
.merge(welcome)
.map(_ + "\n")
.map(ByteString(_))

  connection.handleWith(serverLogic)
}
  }
 }



But when I connect to localhost/ via telnet, type in a few lines, and 
watch the traffic with wireshark, I'm seeing various retransmits and out of 
order:

46482→ [SYN] Seq=0 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=47383693 
TSecr=0 WS=128 
→46482 [SYN, ACK] Seq=0 Ack=1 Win=43690 Len=0 MSS=65495 SACK_PERM=1 
TSval=47383693 TSecr=47383693 WS=128 
46482→ [ACK] Seq=1 Ack=1 Win=43776 Len=0 TSval=47383693 TSecr=47383693 
→46482 [PSH, ACK] Seq=1 Ack=1 Win=43776 Len=56 TSval=47383719 
TSecr=47383693 
46482→ [ACK] Seq=1 Ack=57 Win=43776 Len=0 TSval=47383719 TSecr=47383719 
[TCP Out-Of-Order] 46482→ [SYN] Seq=0 Win=43690 Len=0 MSS=65495 
SACK_PERM=1 TSval=47383693 TSecr=0 WS=128 
[TCP Retransmission] →46482 [SYN, ACK] Seq=0 Ack=1 Win=43690 Len=0 
MSS=65495 SACK_PERM=1 TSval=47383693 TSecr=47383693 WS=128 
46482→ [ACK] Seq=1 Ack=1 Win=43776 Len=0 TSval=47383693 TSecr=47383693 
[TCP Retransmission] →46482 [PSH, ACK] Seq=1 Ack=1 Win=43776 Len=56 
TSval=47383719 TSecr=47383693 
46482→ [ACK] Seq=1 Ack=57 Win=43776 Len=0 TSval=47383719 TSecr=47383719 
46482→ [PSH, ACK] Seq=1 Ack=57 Win=43776 Len=6 TSval=47384746 
TSecr=47383719 
→46482 [ACK] Seq=57 Ack=7 Win=43776 Len=0 TSval=47384746 TSecr=47384746 
→46482 [PSH, ACK] Seq=57 Ack=7 Win=43776 Len=7 TSval=47384747 
TSecr=47384746 
46482→ [ACK] Seq=7 Ack=64 Win=43776 Len=0 TSval=47384747 TSecr=47384747 
[TCP Retransmission] 46482→ [PSH, ACK] Seq=1 Ack=57 Win=43776 Len=6 
TSval=47384746 TSecr=47383719 
→46482 [ACK] Seq=57 Ack=7 Win=43776 Len=0 TSval=47384746 TSecr=47384746 
[TCP Retransmission] →46482 [PSH, ACK] Seq=57 Ack=7 Win=43776 Len=7 
TSval=47384747 TSecr=47384746 
46482→ [ACK] Seq=7 Ack=64 Win=43776 Len=0 TSval=47384747 TSecr=47384747 
46482→ [PSH, ACK] Seq=7 Ack=64 Win=43776 Len=6 TSval=47386128 
TSecr=47384747 
→46482 [PSH, ACK] Seq=64 Ack=13 Win=43776 Len=7 TSval=47386129 
TSecr=47386128 
46482→ [ACK] Seq=13 Ack=71 Win=43776 Len=0 TSval=47386129 TSecr=47386129 
[TCP Retransmission] 46482→ [PSH, ACK] Seq=7 Ack=64 Win=43776 Len=6 
TSval=47386128 TSecr=47384747 
[TCP Retransmission] →46482 [PSH, ACK] Seq=64 Ack=13 Win=43776 Len=7 
TSval=47386129 TSecr=47386128 
46482→ [ACK] Seq=13 Ack=71 Win=43776 Len=0 TSval=47386129 TSecr=47386129 

Full trace at http://pastebin.com/09xi1kGa

Could someone explain to me if I'm doing something wrong, or what's going 
on?







-- 
>>  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] Akka Persistence - callback for persistAll when all events have been saved

2016-02-28 Thread Łukasz Gąsior
Thanks! 
I think that's exactly what I need, and now that I know about it I see a 
section in docs right above 
"Nested persist calls", which I was looking at before posting my question.

Cheers

W dniu niedziela, 28 lutego 2016 15:50:55 UTC+1 użytkownik Konrad Malawski 
napisał:
>
> A defer() just after the persistAll call should pretty much be what you 
> need, unless I missed something :)
> On Feb 28, 2016 15:23, "Łukasz Gąsior" > 
> wrote:
>
>> Hi,
>>
>> Is there a way to execute a handler when all events have been saved using 
>> persistAll?
>> i.e. have (handler: Seq[A] => Unit) or even (handler: () => Unit)
>>
>> Cheers,
>> Łukasz
>>
>> -- 
>> >> 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.
>>
>

-- 
>>  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] Akka Persistence - callback for persistAll when all events have been saved

2016-02-28 Thread Konrad Malawski
A defer() just after the persistAll call should pretty much be what you
need, unless I missed something :)
On Feb 28, 2016 15:23, "Łukasz Gąsior"  wrote:

> Hi,
>
> Is there a way to execute a handler when all events have been saved using
> persistAll?
> i.e. have (handler: Seq[A] => Unit) or even (handler: () => Unit)
>
> Cheers,
> Łukasz
>
> --
> >> 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.


[akka-user] Akka Persistence - callback for persistAll when all events have been saved

2016-02-28 Thread Łukasz Gąsior
Hi,

Is there a way to execute a handler when all events have been saved using 
persistAll?
i.e. have (handler: Seq[A] => Unit) or even (handler: () => Unit)

Cheers,
Łukasz

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