SocketException: No buffer space available (maximum connections reached)

Hi

I am currently doing some load testing of a NIO TCP/IP based Server:

  • Server and Client on same machine.
  • PC: P4, 3GHz, 1GB RAM, Windows XP, SP2

I seem to always reach a limit on the number of connections to the Server (not sending any messages), i.e. using a single client making multiple connection requests to the Server.
After a few 1000 connections (Task Manager: 130k Handles), I get the following exception:

java.io.IOException: …
at …
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
at sun.nio.ch.Net.connect(Native Method)

I have tried the following, (with little or no success):

  • Changing some of the registry settings, e.g. TCPNumConnections, MaxUserPort. (No effect)
  • Using Heap buffers (No effect)
  • Using the compiler options (CPU usage went from 100% to 75%): -Xmn 100M -Xms -500M -Xmx 500M

Will using a non-NIO Client help?

Is this problem Win XP O.S. specific. Does Win XP place a limit on the number of:

  • Simultaneous TCP connections
  • File Handles/Descriptors
  • Socket buffer size

If the problem is O.S. related:

  • Can any of the above parameters be changed, e.g. Registry settings
  • What would the best OS for a Server, e.g. Windows Server 2000/2003, or Linux (which version: Redhat, Fedora, Debian)?

Does PC’s processor speed/RAM have any effect, i.e. will 300MHz, 128 MB be as good as 1GHz, 1GB RAM?

Many Thanks,
Matt :slight_smile:

This may seem like stupid question, but have u got that error really on server?Maybe it was client…

Today we tested our game server against hacker attacks and tried to connect a s many as possible-it turned out that client app died first due to limited amount of connections-nio server didnt give a damn about that num-and it was something between 1000-200 , but i m not sure…

googlein it:
http://www.thescripts.com/forum/thread144674.html

[quote=“link above”]Erland’s already explained what recv is. The buffer the error message is
talking about refers to the TCP/IP stack’s buffers. The error you’re seeing
can be caused by multiple things: too much data queued up for send via
TCP/IP or you’re out of ephemeral sockets. The big problem is that the
number of available ephmeral sockets doesn’t change just because you have a
massive amount of RAM. I’m not a Winsock expert, but running out of
ephemeral sockets is common problem on Windows. Well, not that common, but
it’s a fairly well known occurrence amoung the networking guru’s (I’m not
one of those).
[/quote]

SluX,
The exeception occurs when “using a single client making multiple connection requests to the Server”, i.e. a loop making connections to the Server one after another.

Kova,
I’ve already seen this page, but thanks anyway.

Does any one else (blahblahblahh, Markus_Persson, etc.) have any experience of this problem?

Thanks,
Matt