harmeetsingh-work/naga

Handle disconnect between sending multiple packets

Closed this issue · 6 comments

I'm try to develop class for Apple Push Notification Service.

To create this class you need to:
1) open connection with apple server;
2) send packet to server;
3) handle disconnect or server response(if any error occurred, Apple server 
drop connection);

With naga it's simple, but it doesn't work:
I'm open connection, send 5 packets to apple server(third packet with error for 
testing), then I saw in console that all packets has been sent, but only 1 and 
2 messages has been delivered, then Apple drops connection.

What's wrong?
Naga handle disconnection too late?
Or, maybe, method "packetSent" don't work properly?

PS: sorry for bad English.

Original issue reported on code.google.com by abuhar...@gmail.com on 12 Mar 2011 at 7:39

packetSent will be called whenever a packet has been sent to the outgoing 
buffer. Nothing guarantees that this packet has been read by the sender.
Is this SSL or a plain socket?

Original comment by christof...@gmail.com on 12 Mar 2011 at 8:19

in this SSL

Original comment by abuhar...@gmail.com on 12 Mar 2011 at 8:33

SSL has a separate way to detect close and I think Naga isn't handling it 
properly. That was something I have a good test-case for. File a bug on SSL not 
detecting close properly.

Original comment by christof...@gmail.com on 12 Mar 2011 at 8:36

Thanks for greate nio module..
I met some trouble..

There is 4 java file(EchoServer, EchoClientNoThread, EchoClient, EchoClient22)

question1. 
    EchoClientNoThread#connectionOpened send message, 
     but EchoServer can not receive it.
(a. start server: java spider.net.reallog.examples.EchoServer
 b. run client :  java spider.net.reallog.examples.EchoClientNoThread 100000 0 )



so... I executed in thread mode

question2.    
    in EchoClient22
      connectionOpened method do not sleep and send message, 
      but EchoServer can not receive it.
(a. start server: java spider.net.reallog.examples.EchoServer
 b. run client :  java spider.net.reallog.examples.EchoClient22 100000 0 )



 so in EchoClient  I wrote code.. like thread.sleep a scond.  
      connectionOpened method sleep and it send no message and server get it.

(a. start server: java spider.net.reallog.examples.EchoServer
 b. run client :  java spider.net.reallog.examples.EchoClient 100000 0 )

Question3.
   when I start two client at the same time, packet loss happen.
(a. start server: java spider.net.reallog.examples.EchoServer
 b. run client 1 :  java spider.net.reallog.examples.EchoClient 1000000 0 
 c. run client 2 :  java spider.net.reallog.examples.EchoClient 1000000 0 )
first one send all of message 1000000 records, but second one can not.....

naga is really good module.. I want to use it rather than netty.
please feed back.

Thanks.

Original comment by serversi...@gmail.com on 24 May 2011 at 6:53

Attachments:

one thing..
When I run many client with sleep time it works very well.
(first argument 1000000 is message send loop count, 
  second one is sleep time per every loop)

 a. start server: java spider.net.reallog.examples.EchoServer
 b. run client 1 :  java spider.net.reallog.examples.EchoClient 1000000 1 
 c. run client 2 :  java spider.net.reallog.examples.EchoClient 1000000 1
 d. run client 3 :  java spider.net.reallog.examples.EchoClient 1000000 1
 e. run client 4 :  java spider.net.reallog.examples.EchoClient 1000000 1

---> all of clients work very well..



Original comment by serversi...@gmail.com on 24 May 2011 at 7:03

The SSL-close message should now be correctly handled (you'll get an 
EOFException on the connectionBroken callback when this happens)

Original comment by christof...@gmail.com on 31 Oct 2011 at 10:28

  • Changed state: Fixed