TCP works perfectly. If there is a problem. It is elsewhere.

Implementing message delivery confirmation is a part of a higher level
protocol. If the network/TCP is connected; it will be delivered.

In what environment are you expecting TCP sockets to close all the time?

Here is what happening regarding missing packets 39-55.  Those are packets
that probably exist in the native io buffer. No application can read what
is in there? The assumption is that data in there will be written. However
a socket can be closed while data exists in this buffer.
Your higher level proto needs to send back an ACK with a packet number. You
need to handle this yourself.
On Mar 31, 2014 12:22 PM, "TRAN Antoine" <[email protected]>
wrote:

> Hi,
>
> Goal
> I would like to improve the reliability of our program using Mina.
> From the research and tests I have made, it seems:
>
>  1.  TCP reliability is not enough for messages not to be lost.
>  2.  Mina does not offer message sent acknowledgment.
>  3.  Lost of connection can be detected with the IOException that Mina
> will throw in IoHandlerAdapter#exceptionCaught.
>  4.  If the remote socket is closed when writing to it, Mina will throw an
> WriteToClosedSessionException in IoHandlerAdapter#exceptionCaught.
>
> Based on these statements, I have made a program that will use a buffer in
> case Mina cannot send messages. When the reconnection is done, it will
> flush the buffer and then resend as normal.
>
> Problems
> This is my test. I send 100 messages at 1/sec. I removed the ethernet
> cable after the 39th messages, put it back a few seconds later. As a
> consequence, I lost some messages. Here are some elements that might help.
>
>  1.  The written data are from messages 1 to 39 and from 55 to 100 (so
> some messages are lost).
>  2.  The Mina server and client notice an IOException.
>  3.  The Mina client gets the IOException way too late (after the 53th
> message).
>  4.  The WriteToClosedSessionException that is supposed to contain all the
> messages that could not be sent contains only the messages from 55 to 58
> (expected from 40 to 58).
>
> Questions
>
>  1.  Are the above statements correct?
>  2.  Is my workaround a good solution or does Mina already offer a better
> way of keeping messages before sending them in case of network error?
>
> Thank you.
>
> Yours sincerely,
>
> Antoine
>

Reply via email to