Java.net.SocketException:No Buffer space avaliable (maximum connection reached?): Jvm_bind Solution

Source: Internet
Author: User

No Buffer Space Available2009-06-15 14:03

Java.net.SocketException:NoBufferSpaceAvailable (maximum connections reached?): Jvm_bind2009-04-14 09:10

Company servers in recent days have reported errors, probably run a day to report the following exception.

Java.net.SocketException:No buffer space available (maximum connections reached?): Jvm_bind

is very depressed, reprinted article, seemingly very comprehensive, try.

A friend asked me to help him solve the problem of the Java application on the server, I used business time to go to the scene two times, finally solved the difficult diseases, hurriedly record down, do not want to save once and I as confused working class, I hope I don't forget.

I. Performance of the problem

First, the environment, the server is WINDOWS Server 2003, I am not very familiar with the characteristics of this operating system, just as a normal personal version of the operating system to use. I usually Java server is installed Linux.

SQL SERVER 2005,SP2 used by the database. His database was originally SQL SERVER 2000 and was the migration I helped him do last week.

Middleware uses resin 2.1.17, which is my favorite and familiar servlet container, and the addition of Apache has good web service performance.

Antivirus software use of rising, dual network cards, hardware firewall, what brand I did not control.

So what's the problem?

This one!

Com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host failed. Java.net.SocketException:No buffer space available (maximum connections reached?): Jvm_bind

Resin start, in a short period of normal, but in the absence of access, will be in a few hours after their own death. Static page no problem, that is, based on the HttpWeb server is not dead, involving the database connection , are not.

Second, analysis

This is the first time I have encountered this error, hurry Google.

I first my own platoon is the problem of the program, online, it is said that the database connection is not closed, such comrades are novice, and I myself can be sure that the program is definitely no problem, this error, the location is definitely more than the database connection to the bottom.

The articles on the net are very few, have looked once again, summarizes altogether has the following several reasons.

1. Windows server runs Automatic Updates. Specifically why the automatic update run, it will consume the system so many socket connections , I do not know. However, there is a point, automatic Update will certainly occupy the network bandwidth and CPU, on the server, I think it should be turned off automatic updating, the use of manual Update method.

2. The machine is in a Trojan horse. Trojan will open a lot of backdoor, create a large number of connections , including LAN on the broiler, there are outside the network. This can also cause the machine to appear unable to surf the internet, or the program cannot connect . In the search results, a large number of results are used by SQL Server database server, which is very easy to attract Trojan horse and virus servers, most of which are SQL Server problems, not accidental.

3. Virtual memory configuration is too low. After discovering this problem for the first time, I went to the scene to open the machine and did report a virtual memory error, saying that the virtual content was insufficient.

4. There are improper procedures to create a large number of short connections , because the program is not robust, causing the socket is busy or time_wait state, or the server and the client side of the exception, and the other party is not notified, is still connected , Continue to do write operations.

Third, the hands-on solution

After analysis, will prepare to take measures to write down, my head is not very good, easy to forget things.

The measures below, what to do first, what to do after, see this article friends, can adjust themselves.

1. Optimize the configuration of the resin, the appropriate expansion of the number of connection pools, although not the problem, or slightly expanded a bit. Configuration of remote monitoring, the default does not do directory browsing, blocking the 404 errors, and using Httpd-install to install resin into the service, my friend is the direct start of the console, which is easy to cause the program in the console cache to stop after the top. The hibernate show_sql switch is turned off.

2. Turn off automatic Updates and turn off the background Intelligent Transfer service. When the service is opened, it is discovered that the service window will automatically shut down after 5 seconds, and there are many strange services. At the same time see Norton has been automatically disabled, can not open the fight, the machine has a lot of virus.

3. Anti-virus. Do not see, do not know, a look startled. My friend is really a big hunk, mom, all kinds of viruses are in, but also service it, this server is really pitiful Ah! Sick master also do not give a doctor, for the country service machine, can not have no health insurance. Your father or uncle will treat you. After analysis, the virus has a U disk virus, there are runauto. Viruses, grey pigeons, legendary Trojans, various unknown backdoor and Trojans, are also installed with a remote control of the little things. Downloaded a 360, want to lazy, the results can not be installed at all. deleted the Runauto., (My previous blog has a special description of how to deal with this thing) results C disk will not open, can only be opened in the explorer. It's kind of troublesome. So find the virus a few hiding place, analysis of unknown services, with DOS deleted, or 360 of the file shredding useful. What C: \windows\lsass.exe et cetera, cmd.exe.exe this is too common. The process is not very clear, in short, the last 360 can be installed and updated. 360 This thing is really good, the Trojan has cleared. Now the service window does not automatically shut down, Norton is also normal monitoring, the machine does not have an abnormal open port, no inexplicable service, yes, almost.

4. Optimize server settings. Actually, I don't know how to optimize it. Look, the virtual memory are in the C disk, C disk space has been very little, looked for something to see the clear, to other disk moved, do not understand, dare not to give others move. Reopen the service window, no use of services are open, I am sure of all shut down, what server services, but also open admin$, hurriedly all closed, he this machine does not need. There is what Iis,apache, open is really full, I see also installed Tomcat, simply add resin full open, that is really enough lively, immobility. I certainly do not allow this to happen, kill it all.

5. Check if a program has a vulnerability. Since I also configured a gadget that only my own Google robots could not find (and rejected the robot scan) under resin, I saw that there was an extranet IP that created a large number of connections , but all in time_wait state. It's also very deadly. Look, in addition to this web app, there is a small program that automatically receives data every day. This program is the use of the socket long connection or short connection do not know, have friends concerned about this content can be detailed Google a bit. But this program is not configured to automatically run the boot (I added), may be the external network that the client on the IP is constantly seeking to connect it! Socket.close () is not released immediately , but set to time_wait state, the time default is 240S, that is, 4 minutes. This is too long, with 30 seconds (minimum) on it. When this default value is modified, it is also found that the machine does not have a big port service, which is more than 5000 ports. This also occurs when the "system lacks sufficient buffer space or because the queue is full cannot perform socket operation" Error! And that Web service is configured to more than 10,000 ports! Hurriedly, the operation method is as follows:

1. Start Registry Editor. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
2. New

Value Name: MaxUserPort
Value type: DWORD
Value data: 65534 (write it in decimal notation, if it's hexadecimal, it's Fffe, because 4 F is 65535)
Valid range: 5000-65534 (decimal)
Default: 0x1388 5000 (decimal)

New

Value Name: TcpTimedWaitDelay
Value type: DWORD
Value data: 0000001e (that is, 30, can not use the WINDOWS calculator, very convenient, this represents the number of seconds time_wait)

Ok!

After some toss, I in the deafening roar, finally soothed this crying server, also tamed a few small Trojan horse, well trained my resin server. By the way, there's a Emerson server behind me, and it's like a hiccup every once in a while to scare me.

I hope to spend 1 hours to write this summary, for my own certainly useful, but also hope to help more friends, if reproduced, please indicate the source.

Transferred from: http://lanxin1985.iteye.com/blog/551469

The official source of the solution is: https://support.microsoft.com/zh-cn/help/196271/ When-you-try-to-connect-from-tcp-ports-greater-than-5000-you-receive-t

Java.net.SocketException:No Buffer space avaliable (maximum connection reached?): Jvm_bind Solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.