locked
"Unable to connect to the remote server" Error from Plugin RRS feed

  • Question

  • Hello all,

    Interesting problem.  I have a plugin that is doing a fairly intense amount of processing and back-and-forthing with the CRM web service.  It cranks along quite well for a while, and then I get the error:

    Unable to connect to the remote server

    After that, all calls to ICRMService from the plugin will fail.  Actually, all calls to the web service from any plugin will fail -- it seems like the web service is just shutting down.  It recovers eventually.

    I guess my question is -- is it possible to overload the web service?  I am using a single instance of ICRMService for all of my requests, and am only running one instance of the plugin at a time, but I am making on the order of a couple thousand calls to the web service.  I'm going to try throwing a thread sleep in there and see if it's a timing issue.

    Thanks,
    Sean
    Tuesday, September 1, 2009 12:50 PM

Answers

  • Hi Sean,

    I've had this problem myself. My code was doing a lot of inserts on the CRM Server. I think the problem is caused by the number of ports available on the IIS. This happens when you create too many connections to the server. When all the available ports are used up you get an error message and no new connections can be made. The problem is fixed if you restart IIS or run your code after a while.

    The recommendation is that you use connection sharing. Please see the post at the URL below.
    http://blogs.msdn.com/crm/archive/2007/01/09/best-practices-for-better-performance-from-your-custom-code.aspx

    There is also a possible work around to the problem. 

    You can open up more TCP/IP connections so that you can execute more calls to the CRM webservice, do the following:

    1. Click Start, click Run, type regedit, and then click OK.
    2. Locate and then click the following registry subkey:
            HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters
    3. Click Edit, point to New, click DWORD Value, and then type MaxUserPort.
    4. Double-click MaxUserPort, and then type a decimal value that is larger than 30,000. 

    Note This value controls the number of dynamic ports that are available. The valid range for this value is 5,000-65,534. Specifically, this parameter controls the maximum port number that is used when a program requests any available user port from the system.

    5. Locate the following registry subkey:
            HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters
    6. Click Edit, point to New, click DWORD Value, and then type TcpTimedWaitDelay.
    7. Double-click TcpTimedWaitDelay, and then set a decimal value of 260. 

    Note This parameter determines the length of time that a connection stays in the TIME_WAIT state when it is closed. When a connection is in the TIME_WAIT state, the socket pair cannot be re-used. This is also known as the "2MSL" state. Typically, this value is two times the maximum segment life time on the network.

    8. Exit Registry Editor.
    9. Restart the Microsoft Dynamics CRM server.


    btw putting a force sleep will fix the issue but  I wouldn't recommend it though.


    Hassan.


    Hassan Hussain | http://hassanhussain.wordpress.com/
    Tuesday, September 1, 2009 1:25 PM
  • Have you tried running the plugin in asynchronus mode?

    Tuesday, September 1, 2009 1:02 PM

All replies

  • Have you tried running the plugin in asynchronus mode?

    Tuesday, September 1, 2009 1:02 PM
  • Hi Sean,

    I've had this problem myself. My code was doing a lot of inserts on the CRM Server. I think the problem is caused by the number of ports available on the IIS. This happens when you create too many connections to the server. When all the available ports are used up you get an error message and no new connections can be made. The problem is fixed if you restart IIS or run your code after a while.

    The recommendation is that you use connection sharing. Please see the post at the URL below.
    http://blogs.msdn.com/crm/archive/2007/01/09/best-practices-for-better-performance-from-your-custom-code.aspx

    There is also a possible work around to the problem. 

    You can open up more TCP/IP connections so that you can execute more calls to the CRM webservice, do the following:

    1. Click Start, click Run, type regedit, and then click OK.
    2. Locate and then click the following registry subkey:
            HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters
    3. Click Edit, point to New, click DWORD Value, and then type MaxUserPort.
    4. Double-click MaxUserPort, and then type a decimal value that is larger than 30,000. 

    Note This value controls the number of dynamic ports that are available. The valid range for this value is 5,000-65,534. Specifically, this parameter controls the maximum port number that is used when a program requests any available user port from the system.

    5. Locate the following registry subkey:
            HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters
    6. Click Edit, point to New, click DWORD Value, and then type TcpTimedWaitDelay.
    7. Double-click TcpTimedWaitDelay, and then set a decimal value of 260. 

    Note This parameter determines the length of time that a connection stays in the TIME_WAIT state when it is closed. When a connection is in the TIME_WAIT state, the socket pair cannot be re-used. This is also known as the "2MSL" state. Typically, this value is two times the maximum segment life time on the network.

    8. Exit Registry Editor.
    9. Restart the Microsoft Dynamics CRM server.


    btw putting a force sleep will fix the issue but  I wouldn't recommend it though.


    Hassan.


    Hassan Hussain | http://hassanhussain.wordpress.com/
    Tuesday, September 1, 2009 1:25 PM
  • Have you tried running the plugin in asynchronus mode?


    That worked!  Awesome...thanks!
    Tuesday, September 1, 2009 1:32 PM
  • Hi,

     

    I know this is off the topic and not Related to CRM.

    But thanks this helped me very much and resolved my Error, I had the same Error “Unable to Connect to Remote Server” and it was because I Executed a Project Server 2007 Get Web Method in a loop.

    And I think what happened was that it was TOO MUCH Web Request for the Server.

     

    I implemented “MyWebProjectService.UnsafeAuthenticatedConnectionSharing = true;” to my Web Service and it seems to be working fine now J

    Wednesday, June 23, 2010 9:08 AM