CRM Blog

CRM WebService Error: Only one usage of each socket address (protocol/network address/port) is normally permitted

by Luke Simpson 01.15.09

When performing a data integration or migration into CRM, it is very common to create a .Net application that transforms the data, then pushes the records into CRM using the WebServices.  At times, however, the load of data being pushed to IIS can be more than is acceptable to the default settings in an IIS implementation.  At these high load times, the server might post an error stating "Only one usage of each socket address (protocol/network address/port) is normally permitted (typically under load)."

What is happening, is that connections are being repeatedly opened and closed on the webserver.  When a connection is closed, the connection goes into a TIME_WAIT state for 240 seconds.  This is the default setting.  In this case, the IP being used is typically fixed, which means that the variable is the local port.  By default ports 1024-5000 are available to be used, which means that using default setting you have approximately 4000 ports to be used during a 4 minute span (240 seconds).  So if your code is making more than 16 webservice calls per second, you will exhaust all of the available ports!

 To fix this problem, you can make 2 different registry changes on the CRM Application Server.

  1. Increase the dynamic port range.  As stated above, the default is 5000 but this can be raised up to 65534.
    • Using Regedit, navigate to  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\MaxUserPort (if this key does not exist, create it as DWORD value)
    • Set the value to 65534, or a value of your choice
  2. Reduce the amount of time that the connection is in a TIME_WAIT state.
    • Using Regedit, navigate to  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\TCPTimedWaitDelay (if this key does not exist, create it as DWORD value)
    • Set the value to 30

 By performing the actions above, you are allowing the server to use a far larger number of available ports, and you also allow the server to recycle them faster.  Problem solved!
Filed under:

Comments

# Taylor said on February 3, 2009 12:50 PM:

Thanks Luke.  We just virtualized our development box and this error popped up.  I updated the registry and problem solved.

Although we were not running any sort of integration so I'm not 100% sure why this popped up.  In any case, thanks.

# Rexiology@MSDN said on February 10, 2009 02:20 AM:

When doing bulk data import on CRM 4.0 using self-made application that utilizes CRM SDK to communicate

# Rexiology::Work said on February 10, 2009 02:21 AM:

crosspost from http://blogs.msdn.com/rextang When doing bulk data import on CRM 4.0 using self-made application

# Avadhut said on February 11, 2009 06:02 PM:

I am doing a data migration from a legacy app to MS CRM and have developed a custom migration app. I was trying to solve this problem for a day and was like going to give up before I encountered your page/URL. And it worked !!

Thanks a ton !!

# veggen said on March 11, 2009 11:13 AM:

Hi, your post was of a great help. Thanks for that. Thanks a lot.

Is this effect achievable with VB.Net code by any chance?

# Luke said on March 20, 2009 09:04 AM:

No, I can't think of any adverse effects.  There have been none that I noticed any time i did this.

# Lance said on May 27, 2009 11:41 AM:

Increasing the range of ephemeral ports used for client TCP/IP connections consumes Windows kernel memory. Do not increase the upper limit for this setting to a value higher than is required to accommodate client application socket connections so as to minimize unnecessary consumption of Windows kernel memory.

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Security Check
Please answer the simple math problem below.

(required)