[ 
https://issues.apache.org/jira/browse/DIRMINA-1069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16101063#comment-16101063
 ] 

Wenzhi Wu commented on DIRMINA-1069:
------------------------------------

Hi,Emmanuel:
     Actually I need to establish many connections between my process and 
server.So I need to create a lot of Connector instances.
     Using Mina 2.0.3,it consumes about 30 file handles,such as socket,pipe and 
epoll.It is the same as Mina 2.0.16.
     The code is as below:
           SocketConnector connector = new NioSocketConnector();
           connector.setConnectTimeoutMillis(300);
           MspMinaCodecFactory factory = new MspMinaCodecFactory();
           factory.setMinaDecoder(new MspMinaProtocolDecoder());
           factory.setMinaEncoder(new MspMinaProtocolEncoder());
           KeepAliveMessageFactory heartBeatFactory = new 
MspClientKeepAliveMessage();
           KeepAliveFilter heartBeat = new 
KeepAliveFilter(heartBeatFactory,IdleStatus.READER_IDLE,KeepAliveRequestTimeoutHandler.CLOSE);
           heartBeat.setForwardEvent(true);
           heartBeat.setRequestInterval(10);
           heartBeat.setRequestTimeout(30);     
           connector.getFilterChain().addLast("codec", new 
ProtocolCodecFilter(factory));
           connector.getFilterChain().addLast("heart", heartBeat); 
           connector.setHandler(new DmsMinaIoClientHandler(peerID, 
task.getTaskID()));

           InetSocketAddress addr;
           try {
                        addr = DmsUtils.parseAddress(peerAddr);
                } catch (ConfigError e) {
                        e.printStackTrace();
                        return false;           
           }
           ConnectFuture cf = connector.connect(addr);
           cf.awaitUninterruptibly(350);
           boolean isConnected = cf.isConnected();              
           if(!isConnected){
                connector.dispose(); 
           }
      
     Above is the case that I establish one connection using JDK 1.7.
     Thanks!



> Number of pipe and eventpoll goes up  about 30 when connecting to server with 
> NioSocketConnector
> ------------------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-1069
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-1069
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.3, 2.0.16
>         Environment: Linux version 2.6.32-431.el6.x86_64(CentOS 65)
> Java 1.7.0_75
>            Reporter: Wenzhi Wu
>            Priority: Critical
>         Attachments: After connecting to server successfully.PNG, Before 
> connecting to server.PNG, File descriptors.PNG
>
>
> When connecting to server with NioSocketConnector,number of pipe and 
> eventpoll goes up about 30.When I connect 1000 times,it will consume more 
> file handles,finally exceed linux maximum limits.I think,maybe it is worser.
> Before connecting to server,number of file descriptors is 269.After it,it 
> becomes 301.
> So,how did everybody solve it?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to