Hi all,
I’m new to Mina. Recently I’m writing a client program to communicate a
server using persistent connection. I thought I can reuse IoSesssion to
continuously sending message to the server, that’s when a message is sent,
the session is still kept open, and I can send another message with this
open seession. but I obversed that the session will be closed right after
the first message is sent. Here is the code I used to send message and
receive the response in synchronous manner:
session.getConfig().setUseReadOperation(true);
IoBuffer buf = IoBuffer.allocate(2);
buf.put((byte) 0);
buf.put((byte) 0);
buf.flip();
WriteFuture wf = session.write(buf);
wf = wf.awaitUninterruptibly();
if (wf.getException() != null) {
throw wf.getException();
}
ReadFuture readFuture = session.read();
readFuture.awaitUninterruptibly();
if (readFuture.getException() != null) {
throw readFuture.getException();
}
After the first two bytes are sent, if I want to do the same operation by
sending another two bytes, I got a WriteToClosedSessionException.
Can anyone tell me how to prevent the session being close so that I can
create a persistent connection with the server side?
Thank for all your advices.
Hef