You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Martin J. Wells" <ma...@dot.net.au> on 2005/05/21 16:37:10 UTC

[mina] No buffer space available

Hi there,

I'm trying to do a little NIO load testing and I'm seeing the following
exception (this is on an XP dev box):

java.net.SocketException: No buffer space available (maximum connections
reached?): connect

This occurs when the client gets past about 400 sockets (the server is on
the same machine).

I've upped my registry TcpNumConnections, and I'm not running out of ram.
I've also tried reducing the buffer's on the sockets to 1024 bytes, but this
seems to make no difference on either side.

Any hints on what could be causing this error?

Regards,
Marty


RE: [mina] c# client

Posted by "Martin J. Wells" <ma...@dot.net.au>.
Aaah, nevermind... I discovered the wonder that is the
CumulativeProtocolDecoder. :)
 
 

  _____  

From: Martin J. Wells [mailto:marty@dot.net.au] 
Sent: Monday, 23 May 2005 6:02 PM
To: 'Apache Directory Developers List'
Subject: RE: [mina] c# client


OK. But then how does the message protocol handler know when a message is
done? How do you know you've actually received all the data for a discreet
message?
 
If the answer is this is not handled by default then how is this typically
done in MINA... how do you hold onto inbound client data until a full
message is ready? For example:
 

public class ReverseProtocolHandler extends ProtocolHandlerAdapter

{

    ...
    public void messageReceived( ProtocolSession session,

Object message )

    {

        // Reverse reveiced string

        String str = message.toString();

        StringBuffer buf = new StringBuffer( str.length() );

        for( int i = str.length() - 1; i >= 0; i-- )

        {

            buf.append( str.charAt( i ) );

        }



        // and write it back.

        session.write( buf.toString() );

    }

}
I can test in here whether all the data is available, but if I don't have
the entire message do I have to then implement my own per-client message
buffering?
 
 
 

  _____  

From: Trustin Lee [mailto:trustin@gmail.com] 
Sent: Monday, 23 May 2005 5:56 PM
To: Apache Directory Developers List
Subject: Re: [mina] c# client


Hi Martin,


2005/5/23, Martin J. Wells <ma...@dot.net.au>: 

I'm looking to implement a c# client for a MINA server and was wondering
where I can find some info on the message protocol used. I.e.. how are
message lengths interpreted, is there a magic number header, etc. Can't seem
to locate much in the source... Am I missing something?

 
MINA itself doesn't implement any protocols.  It simply helps you to
implement your or any others' protocols.  If any protocol specification is
not defined, you'll have to define some first, and then implement the server
to conform to that specifiation, and MINA will help you implementing it.
So.. if you're implementing C# client for a server which is made on top of
MINA, actually it dosn't matter whether the server is implemented using MINA
or any other frameworks. 
 
Thanks,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/ 


RE: [mina] c# client

Posted by "Martin J. Wells" <ma...@dot.net.au>.
OK. But then how does the message protocol handler know when a message is
done? How do you know you've actually received all the data for a discreet
message?
 
If the answer is this is not handled by default then how is this typically
done in MINA... how do you hold onto inbound client data until a full
message is ready? For example:
 
public class ReverseProtocolHandler extends ProtocolHandlerAdapter

{

    ...


    public void messageReceived( ProtocolSession session,

Object message )

    {

        // Reverse reveiced string

        String str = message.toString();

        StringBuffer buf = new StringBuffer( str.length() );

        for( int i = str.length() - 1; i >= 0; i-- )

        {

            buf.append( str.charAt( i ) );

        }



        // and write it back.

        session.write( buf.toString() );

    }

}
I can test in here whether all the data is available, but if I don't have
the entire message do I have to then implement my own per-client message
buffering?
 
 
 

  _____  

From: Trustin Lee [mailto:trustin@gmail.com] 
Sent: Monday, 23 May 2005 5:56 PM
To: Apache Directory Developers List
Subject: Re: [mina] c# client


Hi Martin,


2005/5/23, Martin J. Wells <ma...@dot.net.au>: 

I'm looking to implement a c# client for a MINA server and was wondering
where I can find some info on the message protocol used. I.e.. how are
message lengths interpreted, is there a magic number header, etc. Can't seem
to locate much in the source... Am I missing something?

 
MINA itself doesn't implement any protocols.  It simply helps you to
implement your or any others' protocols.  If any protocol specification is
not defined, you'll have to define some first, and then implement the server
to conform to that specifiation, and MINA will help you implementing it.
So.. if you're implementing C# client for a server which is made on top of
MINA, actually it dosn't matter whether the server is implemented using MINA
or any other frameworks. 
 
Thanks,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/ 


Re: [mina] c# client

Posted by Trustin Lee <tr...@gmail.com>.
Hi Martin,

2005/5/23, Martin J. Wells <ma...@dot.net.au>: 
> 
> I'm looking to implement a c# client for a MINA server and was wondering
> where I can find some info on the message protocol used. I.e.. how are
> message lengths interpreted, is there a magic number header, etc. Can't 
> seem
> to locate much in the source... Am I missing something?

 MINA itself doesn't implement any protocols. It simply helps you to 
implement your or any others' protocols. If any protocol specification is 
not defined, you'll have to define some first, and then implement the server 
to conform to that specifiation, and MINA will help you implementing it. 
So.. if you're implementing C# client for a server which is made on top of 
MINA, actually it dosn't matter whether the server is implemented using MINA 
or any other frameworks.
 Thanks,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/

RE: [mina] No buffer space available

Posted by "Martin J. Wells" <ma...@dot.net.au>.
> > 
> > I'm trying to do a little NIO load testing and I'm seeing the 
> > following exception (this is on an XP dev box):
> > 
> > java.net.SocketException: No buffer space available (maximum 
> > connections
> > reached?): connect
> 
> First off, what startup options are you passing to the JVM?  
> Also, the error message also seems to indicate that you are 
> running out of file handles (descriptors).

I tracked this down to file handles on Win XP, which seemed to be hard set.
I finally just moved everything over to Linux boxes and had 60000+ with no
trouble. :)

Regards,
Marty


[mina] c# client

Posted by "Martin J. Wells" <ma...@dot.net.au>.
Hi guys,

I'm looking to implement a c# client for a MINA server and was wondering
where I can find some info on the message protocol used. I.e.. how are
message lengths interpreted, is there a magic number header, etc. Can't seem
to locate much in the source... Am I missing something?

Regards,
Marty


Re: [mina] No buffer space available

Posted by Vinod Panicker <vi...@gmail.com>.
Hi Martin,

On 5/21/05, Martin J. Wells <ma...@dot.net.au> wrote:
> Hi there,
> 
> I'm trying to do a little NIO load testing and I'm seeing the following
> exception (this is on an XP dev box):
> 
> java.net.SocketException: No buffer space available (maximum connections
> reached?): connect

First off, what startup options are you passing to the JVM?  Also, the
error message also seems to indicate that you are running out of file
handles (descriptors).

> This occurs when the client gets past about 400 sockets (the server is on
> the same machine).

Remember that the client will actually be using up file handles as
well as available port numbers, and the server will be using up just
file handles.  Also on Windows, each socket doesnt necessarily mean a
single file handle getting used.  In my tests, I've seen multiple file
handles being used up for a single socket connection.

> I've upped my registry TcpNumConnections, and I'm not running out of ram.
> I've also tried reducing the buffer's on the sockets to 1024 bytes, but this
> seems to make no difference on either side.

Try upping the default memory values used by the JVM by passing starup
options (Xss and something else I forget.  do look it up)

HTH,
Vinod.

PS: I'd recommend that you do these tests on a server OS such as
Windows 2003 Server or Windows 2000 Server.  MS does place limits on
other desktop OS's.