Because you dont use the join() method in the WriteFuture. If you write
like this:
MinaConnectionObj.sessions.get(key).write(DataPacketObj).join();
the thread will wait until the packet has been sent. Otherwise you will
only send your packet to MINA but there is no guarantee that the packet
will be sent to the client right away.
> Hi,
>
> Consider the following:
>
> a) Client connects to Server
> b) For the session ProtocolCodecFilter and KeepAliveFilter's are added on
> both sides
> c) KeepAliveFilter is aimed for keepalive packets to be sent from client
> to
> server to enable a long lasting connection
>
> Every 5 minutes
> d) The server push's data to the client using the same session on the
> serverside that was created when the client connected
>
> This push from the server to the client happens for the first time and
> during subsequent times it does not happen.
>
> Code :
>
> try {
> WriteFuture WriteFutureObj =
> MinaConnectionObj.sessions.get(key).write(DataPacketObj);
> System.out.println("----- > Status : " +
> MinaConnectionObj.sessions.get(key) + " " +
> MinaConnectionObj.sessions.get(key).isConnected() + " " +
> WriteFutureObj.isWritten());
> } catch (Throwable Ex) {
> }
>
> Strangely I get the following output everytime:
> ----- > Status : (0x00C8CDCA: nio socket, server, /127.0.0.1:4734 => /
> 127.0.0.1:5401) true false
> ----- > Status : (0x00C8CDCA: nio socket, server, /127.0.0.1:4734 => /
> 127.0.0.1:5401) true false
> ----- > Status : (0x00C8CDCA: nio socket, server, /127.0.0.1:4734 => /
> 127.0.0.1:5401) true false
> ----- > Status : (0x00C8CDCA: nio socket, server, /127.0.0.1:4734 => /
> 127.0.0.1:5401) true false
>
> Which means that the connection still exists and is connected. Why isnt
> the
> data going back to the client?
>
> Pat
>