mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Akbar Munir Chaudhary <ak...@acm.org>
Subject Re: IoHandler notifications not being called by Mina v1.0 for localhost
Date Mon, 20 Nov 2006 16:31:15 GMT
Below is the code for the client and the server classes. The "CIoHandler" class is simply the
implementation of IoHandler interface, with single System.out.println statement for each of
the notification. I only get "sessionCreated" notification on both client and server side.

-----------------
Client Code
-----------------
public class CClient
{
    public static void main(String[] a_strArrayOfArguments) throws Exception
    {
    IoSession oIOSession = null;
    ConnectFuture oConnectFuture = new SocketConnector().connect(new InetSocketAddress("localhost",
1122), new CIoHandler());
    oConnectFuture.join();
    if(oConnectFuture.isConnected())
    {
        WriteFuture oWriteFuture = null;
        ByteBuffer oByteBuffer = ByteBuffer.allocate(256);
        oIOSession = oConnectFuture.getSession();
        System.out.println("Connected = " + oIOSession.isConnected());
        
        oByteBuffer.put(new String("This is a test message from the client").getBytes());
        oByteBuffer.flip();
        oWriteFuture = oIOSession.write(oByteBuffer);
        oWriteFuture.join();
        if(oWriteFuture.isWritten())
        {
        System.out.println("Message written");
        }
        else
        {
        System.out.println("Message CAN NOT be written.");
        }
        
        CloseFuture oCloseFuture = oIOSession.close();
        oCloseFuture.join();
        if(oCloseFuture.isClosed())
        {
        System.out.println("Session closed");
        }
        else
        {
        System.out.println("Session CAN NOT be closed");
        }
    }
    else
    {
        System.out.println("Error connecting to server");
    }
    }
}

-------------------
Server Code
-------------------
public class CServer
{
    public static void main(String[] a_strArrayOfArguments) throws Exception
    {
    new SocketAcceptor().bind(new InetSocketAddress(1122), new CIoHandler(), null);
    System.out.println("Server started");
    }
}


----- Original Message ----
From: Niklas Therning <niklas@trillian.se>
To: dev@mina.apache.org
Sent: Monday, November 20, 2006 8:20:10 PM
Subject: Re: IoHandler notifications not being called by Mina v1.0 for localhost

Pleae post the code of your client if possible.

/Niklas

Akbar Munir Chaudhary wrote:
> I have recently switched to Mina v1 from v0.8. Though it must be a trivial mistake on
my side, but i am not able to receive any message that is sent from client to server or from
server to client. I did write the most basic client and server, without the protocol layer,
using on ly the IoHandler. The "sessionCreated" is called on both sides. The notification
"sessionOpened", "messageReceived" and "messageSent" are never called. I then tried using
my client with a third party server. The message from my client to the server reached successfully
but the server's message to my client was never received (the fact that "messageReceived"
was never called).
>
> As a 2nd step, I compiled the reverser application that comes with MINA and used it with
3rd party client. The reverser server did not receive any message from the client.
>
> I am using Java 5 (Update 9) on Windows XP (SP2). Was not able to use Ethereal to sniff
traffic, as I was testing only on localhost, for which Ethereal does not work on Windows.
Any help or pointers as to my mistake will be greatly appreciated.
>
> Thanks,
> Akbar.
>
>
>
>   


-- 
Niklas Therning
www.spamdrain.net








Mime
View raw message