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

Source: Internet
Author: User

An exception occurred in the crawler's operation,
Java.net.SocketException:No buffer space available (maximum connections reached?): Jvm_bin

The httpclient is used in reptiles, and the thread pool is used.

Search the next found that other people have similar problems, the solution is as follows, according to change the program to see if the future operation will also appear this problem.

From http://9iopen.group.javaeye.com/group/blog/144545

The following exception was encountered in a crawler program:
Java.net.SocketException No buffer space available (maximum connections reached?): Jvm_bind

We know that the operating system has the maximum number of file handles that it allows to hold, while in the process of network connection, each socket request occupies a file handle resource, and if it is not released in time, it may deplete the file handle resource.
By examining the code, you find that when you send a GET request using httpclient, you do not release the resource, and because it is multithreaded, it is easy to run out of resources
The rewritten code is as follows: Java code httpclient client =   New  httpclient ();    getmethod method =  null;    try  {   method =  new  getmethod (Crawlerurl.getuuri (). Getescapeduri ());    Statuscode = client.executemethod (method);   /...   }    finally  {   if   (null  != method)  &N Bsp Method.releaseconnection ();   }  

One answer to the Sun's Technical forum is this:
Chances are you are forgetting to close a socket, a database connection, or some other connection this uses sockets Ally. Example program below.
The alternative is this your program (or the sum of all programs running on your computer) really needs a lot of connectio Ns. In this case you'll need to the increase the amount of socket buffer spaces that your operating system allocate S. I ' d start by Googling for instructions. Or Maybe you could redesign your program so, that it doesn ' t is very much.

For more answers to this question, see here:
http://forum.java.sun.com/thread.jspa?threadID=556382

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.