Hi Ashish,

I just cannot reproduce your problem.  I tested with the following code:

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;



public class Foo {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("localhost", 5683);
        InputStream in = s.getInputStream();
        OutputStream out = s.getOutputStream();
        BufferedReader reader = new BufferedReader(new
InputStreamReader(in, "UTF-8"));
        OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
        while(true) {
            writer.write("jmd\n");
            writer.flush();
            System.out.println(reader.readLine());
        }
    }
}


You might try the default charset instead of UTF-8 though.

HTH,
Trustin

On Jan 7, 2008 3:34 AM, Ashish Sharma <[EMAIL PROTECTED]> wrote:
> Hi
> I am using mina core 2 snap shot "mina-core-2.0.0-M1-20071219.081925-109".
>
> Here is the code snippet of the time server
>
>         IoAcceptor acceptor = new NioSocketAcceptor();
>
>         acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(
>                 new TextLineCodecFactory(Charset.forName("UTF-8"))));
>
>         acceptor.setHandler(new TimeServerHandler());
>
>         acceptor.setDefaultLocalAddress(new InetSocketAddress(5683));
>         acceptor.bind();
>
> complete code can be found at http://pastebin.com/f22ec4749
>
> I have executed the same program on both windows and linux platforms and the
> problem is the same. When my client connects to mina server, i can see a lot
> of "message written..." lines in server's terminal window but hardly any
> messages reach client. Here is the client code snippet.
>
>         while(true) {
>             writer.write("jmd\n");
>             writer.flush();
>         }
>
> A sleep of 10 solves the problem. But this behaviour seems to contradict
> this:
>
> I'm not able to answer your Q 1 and 3 right now, but I can assure you
> > that MINA can handle high load from many clients. We are using it into
> > Apache Directory Server, and were able to simulate this with hundreds of
> > clients and thousands of messages per second, for hours ( we did a test
> > which lasted 72 hours, for hundreds of millions messages).
> >
>
> I hope i am configuring something wrong here. Please let me know.
>
> Thanks
> Ashish
>
>
>
> On Dec 28, 2007 8:55 AM, Trustin Lee <[EMAIL PROTECTED]> wrote:
>
> > Hi Ashish,
> >
> > On Dec 28, 2007 2:21 AM, Ashish Sharma <[EMAIL PROTECTED]> wrote:
> > > Hi
> > >
> > > Recently I have been experimenting with mina core 2 and I have a few
> > > questions regarding the behaviour of mina in some sample programs I
> > made.
> > >
> > > here is the client code. its simple, it simply rams as many messages as
> > > possible into the server.
> > >
> > > http://pastebin.com/m14ac361e
> > >
> > > Now I made two servers. One mina based, which is simply the date/time
> > echo
> > > server as described in the documentation. The second one is a simple
> > "one
> > > thread per client" server. Here is the code
> > http://pastebin.com/m3a5a14a7
> > >
> > > Now the result from both the servers differ a lot. The second server
> > works
> > > in lock step with client and responds to messages without any delay. But
> > > with mina server the response is very slow and after about 10 messages
> > the
> > > response is almost nill and after a few seconds I start getting out of
> > > memory exceptions while creating more date objects.
> > >
> > >
> > > Now I have the following questions (I very good spirit)
> > >
> > > 1. What is the reason behind this behaviour ?
> >
> > Please make sure that you are using heap buffers and configured the
> > thread model correctly.  And I hope you are using the latest stable
> > release.
> >
> > > 3. Is there a solution to this ? IMHO, first server example demonstrates
> > > that such high load can be handled at server.
> >
> > If your client connects and disconnects very frequently, it might slow
> > down your MINA application.  Please try to keep the connection alive
> > whenever possible.
> >
> > HTH,
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
>



-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to