How to Solve Max Connection Pool Error

后端 未结 4 1627
执笔经年
执笔经年 2020-12-05 10:10

I have a application in asp.net 3.5 and Database is Sql server 2005.

\"Timeout expired.  The timeout period elapsed prior to obtaining a connection from the          


        
4条回答
  •  孤街浪徒
    2020-12-05 11:04

    Here's what u can also try....

    run your application....while it is still running launch your command prompt

    while your application is running type netstat -n on the command prompt. You should see a list of TCP/IP connections. Check if your list is not very long. Ideally you should have less than 5 connections in the list. Check the status of the connections.
    If you have too many connections with a TIME_WAIT status it means the connection has been closed and is waiting for the OS to release the resources. If you are running on Windows, the default ephemeral port rang is between 1024 and 5000 and the default time it takes Windows to release the resource from TIME_WAIT status is 4 minutes. So if your application used more then 3976 connections in less then 4 minutes, you will get the exception you got.

    Suggestions to fix it:

    1. Add a connection pool to your connection string.

    If you continue to receive the same error message (which is highly unlikely) you can then try the following: (Please don't do it if you are not familiar with the Windows registry)

    1. Run regedit from your run command. In the registry editor look for this registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters:

    Modify the settings so they read:

    MaxUserPort = dword:00004e20 (10,000 decimal) TcpTimedWaitDelay = dword:0000001e (30 decimal)

    This will increase the number of ports to 10,000 and reduce the time to release freed tcp/ip connections.

    Only use suggestion 2 if 1 fails.

    Thank you.

提交回复
热议问题