2

I am looking a solution of the exception java.net.SocketException: No buffer space available (maximum connections reached?) that I am getting in my Logs.

Environment: Windows Server 2008 R2 JDK 7 update 25

Stack Trace:

java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind at java.net.TwoStacksPlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.TwoStacksPlainSocketImpl.bind(TwoStacksPlainSocketImpl.java:101)

The solution that I am getting in all the hits-

The solution is to open the registry editor and locate the registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters and add a new entry as shown below:

Value Name: MaxUserPort
Value Type: DWORD
Value data: 65534

Increasing the number of ephemeral TCP ports in registry, is the right solution? What is the other solution? Is there any other programmatic approach to manage and close the these socket connections?

Ashish Pancholi
  • 4,569
  • 13
  • 50
  • 88
  • 2
    Why are you opening these many connections in the first place? Are you not closing the connections after using them? – Narendra Pathai Aug 27 '13 at 11:15
  • It actually looks like you are trying to *listen* on a huge number of sockets, unless you are calling `bind()` yourself for some reason on your client sockets, in which case the simple answer is "don't". – user207421 Aug 28 '13 at 01:21
  • I followed this solution(http://stackoverflow.com/questions/10088363/java-net-socketexception-no-buffer-space-available-maximum-connections-reached) that recommended downloading a patch to fix this error. It didn't work, but updating the MaxUserPort registry key like you suggested did. Thank You. – Alex Sep 02 '14 at 21:17

0 Answers0