Windows under Socket link overflow

Source: Internet
Author: User

Most recently, using the JDBC Operations database with multithreading under Windows, the number of threads is set to 5, and after each thread completes sleep (1000), in this case, the error is also:

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

A look at this type of error, should belong to the socket connection is not closed or waiting, because I use JDBC to operate the database, and is a short connection form, that is, each time an operation to create a new JDBC connection, the operation is completed to close the JDBC connection, The JDBC connection is based on the socket, then the problem should appear on the JDBC Connection database, plus I use the original script written by the Java program, and no framework and the Web container, so there is no JDBC connection pool to help me control the JDBC connection shutdown. After a variety of attempts and Google, it is possible that the Windows system-level socket settings are the cause.

The solution 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 (decimal)

Valid range: 5000-65534 (decimal)

Default: 0x1388 5000 (decimal)

New

Value Name: TcpTimedWaitDelay

Value type: DWORD

Value data: 30 (this represents the number of seconds time_wait)

The most important of these is tcptimedwaitdelay, if a socket connection waits longer than 30 seconds, the connection is closed.

Run the program again, and now set the number of threads to 30, and the program will still work.

Windows under Socket link overflow

Related Article

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.