You're probably reaching an OS limit on memory required by the OS to manage socket. Can you try the same test without the connector.getSessionConfig().setReadBufferSize(1024); statement ?
Jeff On Wed, Oct 2, 2013 at 6:41 AM, kishore <[email protected]> wrote: > Hi, > > I have written the following program to test the MINA framework. I am > trying > to test the number of concurrent connections that can be opened on my > windows 2008 server. But hen i reach 1000 connections it is giving the > following error > "java.net.SocketException: No buffer space available (maximum connections > reached?): connect" > > below is my source > > > package Research; > > import java.net.InetSocketAddress; > import java.nio.charset.Charset; > > import org.apache.mina.core.buffer.IoBuffer; > import org.apache.mina.core.buffer.SimpleBufferAllocator; > import org.apache.mina.core.future.ConnectFuture; > import org.apache.mina.core.service.IoConnector; > import org.apache.mina.core.session.IoSession; > import org.apache.mina.filter.codec.ProtocolCodecFilter; > import org.apache.mina.filter.codec.textline.TextLineCodecFactory; > import org.apache.mina.transport.socket.nio.NioSocketConnector; > > public class SocketTest { > > static int sucess=0,failure=0; > static String serverIP,localIp; > static int serverPort=1234; > static int initialPort=30000; > static int numberofports=5000; > static IoConnector connector; > > static{ > > boolean useHeapBuffers=false; > IoBuffer.setUseDirectBuffer(!useHeapBuffers); > if (useHeapBuffers) { > IoBuffer.setAllocator(new SimpleBufferAllocator()); > } > connector = new NioSocketConnector(); > connector.getFilterChain().addLast("codec",new > ProtocolCodecFilter(new > TextLineCodecFactory(Charset.forName("UTF-8")))); > connector.setHandler(new MinaClientHandler_executor("hello > server")); > connector.getSessionConfig().setReadBufferSize(1024); > > > > } > > public static void main(String args[]) throws Exception > { > if(args[0]!= null) > serverIP=args[0]; > else > throw new Exception("ServerIp can not be nempty"); > > if(args[1] != null) > serverPort=Integer.parseInt(args[1]); > > else > throw new Exception("Port can not be nempty"); > > if(args[2] != null) > numberofports=Integer.parseInt(args[2]); > > System.out.println("initial port ::: "+(numberofports)); > > > for(int i=initialPort;i<(initialPort+numberofports);i++) > { > final int portNumber=i; > > try { > > ConnectFuture future = > connector.connect(new > InetSocketAddress(serverIP,serverPort)); > > future.awaitUninterruptibly(); > > if (!future.isConnected()) > { > throw new Exception("port is > already in > use"+future.getException()+">>>>>>>>>>>>"); > } > IoSession session = future.getSession(); > > sucess++; > System.out.println("Opened Socket > ..."+portNumber); > System.out.println("Sucess ::"+sucess+" > failure ::"+failure); > } catch (Exception e) { > failure++; > System.out.println("Error Opening Socket > ..."+portNumber +"Error :: > "+e.getMessage()); > System.out.println("Sucess ::"+sucess+" > failure ::"+failure); > } > > Thread.sleep(100); > > } > > > > } > } > > > > > -- > View this message in context: > http://apache-mina.10907.n7.nabble.com/NIO-Client-Sockets-No-Buffer-space-error-tp39978.html > Sent from the Apache MINA Developer Forum mailing list archive at > Nabble.com. > -- Jeff MAURY "Legacy code" often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury
