You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "hl.0074" <hl...@gmail.com> on 2013/09/28 06:42:03 UTC

Why Mina IOSession can not send message sometimes?

hi
i found a problem with mina these days,sometimes,IOSession.write(Object) can't write the message as i expected,the writeFuture.isWritten is false when write operationComplete ,here is some code in my project i wrote:

public void sendMessage(SocketMessage sm){
System.out.println("client send.....");
WriteFuture wf = this.ioSession.write(sm);
wf.addListener(new IoFutureListener<IoFuture>() {

@Override
public void operationComplete(IoFuture future) {

if (!((WriteFuture) future).isWritten()) {
System.out.println("writen false...");
sendMessage(sm);
} else {
        System.out.println("writen success....");
}
}
}

sometimes i got the logs like this,



it has been resend 300+ times,but this situation is not offten appears,is it a bug or i miss something ?

thanks
2013-09-28 12:39







hl.0074

Re: Why Mina IOSession can not send message sometimes?

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 9/27/13 9:42 PM, hl.0074 a écrit :
> hi
> i found a problem with mina these days,sometimes,IOSession.write(Object) can't write the message as i expected,the writeFuture.isWritten is false when write operationComplete ,here is some code in my project i wrote:
>
> public void sendMessage(SocketMessage sm){
> System.out.println("client send.....");
> WriteFuture wf = this.ioSession.write(sm);
> wf.addListener(new IoFutureListener<IoFuture>() {
>
> @Override
> public void operationComplete(IoFuture future) {
>
> if (!((WriteFuture) future).isWritten()) {
> System.out.println("writen false...");
> sendMessage(sm);
> } else {
>         System.out.println("writen success....");
> }
> }
> }
>
> sometimes i got the logs like this,
>
>
>
> it has been resend 300+ times,but this situation is not offten appears,is it a bug or i miss something ?


It's a bit difficult to know if it's a bug if we don't have more
information about the version you use and the kind of transport you are
using.

In any case, you should rather handle the messageSent event in your
IoHandler, this tells you when the message has been writen without
having to check the Future.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com