directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Zago <>
Subject Re: [mina] Suggestions for a proxy server
Date Sun, 24 Apr 2005 17:15:23 GMT
I did some more deep tests.
The server is very simple, I created a server only to receive messages. 
So the start up code is...
 IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
         // and start both.
         // Create a TCP/IP acceptor.
         IoAcceptor acceptor = new SocketAcceptor();
         // Add both thread pool filters.
         acceptor.getFilterChain().addFirst("threadPool", ioThreadPoolFilter );
          // Bind
          acceptor.bind( new InetSocketAddress( PORT ), new
SocketProtocolHandler() );
          System.out.println( "Listening on port " + PORT );

the SocketProtocolHandler is very simple system.out in every method.
The client is attached to this email..  it's open a connections end a
message anc close.
What I can see from log is..the OPEN session, the Close
the most of cases.
In some occasion rarely I see the received message.
I tried not to use IoThreadPoolFilter, but the result is the same.
I tried the same client with a very similar server in Netty2. And it
works fine, it receives all the messages, I am agree with you it can
be a thread issue inside Mina.
have you any suggestions?

Thanks a lot in advance,

On 4/24/05, Trustin Lee <> wrote:
> Hi,
> 2005/4/24, Luca Zago <>:
> > Hi Guys,
> > to understand how mina works, I am building a small proxy server, the
> > functionality is quite easy, a client connect and send a message, the
> > server broadcasts the message to all connected clients. I am facing
> > two main problems:
> It's a kind of chatroom server, right?
> > 1) I don't understand if in mina there is a class which keeps all the
> > opened session by an acceptor. And where I can manage the writing of
> > the message in all the sessions opened?
> > I was trying to keep the opened session in a vector inside my
> > IoHandler class  and writing back the message in dataRead method to
> > each session in the vector. But it doesn't seem a thread safe way of
> > managing it.
> There's no such class for now.  I think you're doing right.  I would
> use Cursorable LinkedList from Jakarta Commons Collections which is
> better when you iterate the list.
> > 2) I  have a simple client to send a message, it looks client:
> > wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
> > wr.write("aString\n");
> > wr.flush();
> > wr.close();
> > I run it many times..and on my server randomly I see my daRead method
> > called, in the most of the times I see an opened and then immediately
> > closed session. It seems it's too fast and the server looses the
> > dataRead event. The server is built like the EchoServer in the
> > example, with SocketAcceptor and IoThreadPoolFilter. Is it a problem
> > of some configuration parameters?
> Did you log any messages when server receives any data so that we can
> confirm any data is lost?  If you didn't and just replied the data
> back to client silently, The connection might be closed already when
> you reply to client due to the sideeffect of thread pool.  Otherwise,
> I'll test by myself, and try to reproduce this issue.  Of course any
> test case code is appreciated.
> Thanks,
> Trustin
> --
> what we call human nature is actually human habit
> --

View raw message