mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: use mina as a tcp client performance
Date Fri, 16 May 2014 07:53:02 GMT
Le 08/05/2014 08:59, pongjy123 a écrit :
> hello,all

Hi,

first, please send such mail to the users mailing list?. You are more
likely to get an answer. The dev list has a limited number of
subscribers, those who are working on MINA code.

Sorry for the delayed response, The ASF has experimented some huge
trouble this past 10 days with their mail system, this mail has only be
received yesterday...
>
>
> I have a problem,I have a java process(mina tcp client), need to connect 1000+ tcp server,my
code is :
> connector = new NioSocketConnector();
> connector.getFilterChain().addLast("clientCodec", new ProtocolCodecFilter(new SplCodecFactory(true,
type)));
> connector.getSessionConfig().setReadBufferSize(MAX_READ_BUFF_SIZE);
> connector.getSessionConfig().setUseReadOperation(true);
> connector.setHandler(new SplClientIoHandler(this.receiver, connectorManager));
> int count = 3;
> while(--count >= 0){
> if(count < 2){
> logger.warn("retry connect count:"+count+",addr:"+addr);
> }
> ConnectFuture connFuture = connector.connect(addr);
> connFuture.awaitUninterruptibly(CONNECT_TIMEOUT);
> session = connFuture.getSession();
> if(session == null){
> if(count == 0){
> throw new Exception("session is null!" + addr);
> }
> }else{
> break;
> }
> }
> connectState = ConnectState.CONNECTED;


This is the correct way to connect to the client, assuming you aren't
creating a new Connector for every single client.

Which version of MINA are you using ? Can you post us a threadDump, I'll
be curious to know what are those 1000 threads you are having (actually,
if you could have a test with 20 clients instead of 1000, that would be
easier ;-). Thanks !



Mime
View raw message