none
.NET重复调用CRM Webservice几千次后出现错误:通常每个套接字地址(协议/网络地址/端口)只允许使用一次 RRS feed

  • 问题

  • 在原来的CRM服务器上没有这个情况,后来换了一台新的服务器,在上边进行调用CRM Webservice时就帮出现了这个错误,不知道是不是要更改服务器上的一些设置(注册表或IIS ???)。请问有没有高人能给予指点,感激不尽!
    2011年8月26日 17:35

答案

  • 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!

    2011年8月29日 3:54

全部回复

  • 服务器上的web资源是有限的,包括端口、连接数等等,当大量调用的时候,可能会把类似于端口号的资源全部占用掉,此时,就会出现类似于“基础连接已经关闭”或者你题目中提到的错误描述。

    我曾经找到的解决的方法是修改服务器操作系统中的端口数量,你可以从google去查找一下。


    daemon lin
    2011年8月27日 5:47
  • 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!

    2011年8月29日 3:54