Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

CRM connection timeout

Posted on by 255

Hi all

I'm trying to switch to OAuth from a c# website connection to CRM online.

I see a constant timeout when trying to connect.
It seems OK in a console app though.

My test script is;

using Microsoft.Xrm.Tooling.Connector;
using System;
using System.Net;


public partial class c2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string sResult = "";
        string connectionString = "AuthType=OAuth;Username = info@xxxx.com;Password=xxxx;Url=https://xxxx.crm4.dynamics.com;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Never";
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        var service = new CrmServiceClient(connectionString);

        if (service.IsReady)
        {
            sResult = "YES";
        }
        else
        {
            sResult = "NO";
        }
        
    }
}

HELP PLEASE!

  • Stuie Profile Picture
    Stuie 255 on at
    RE: CRM connection timeout

    But should it need so long to connect?

    My application cannot really take so long to run.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: CRM connection timeout

    Hi,

    You will need to use MaxConnectionTimeout  property to extend the timeout. Default is 2 mins.

    docs.microsoft.com/.../microsoft.xrm.tooling.connector.crmserviceclient.maxconnectiontimeout

    ramontebar.net/.../

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Stuie Profile Picture
    Stuie 255 on at
    RE: CRM connection timeout

    Also, I cant seem to use Microsoft.PowerPlatform.Dataverse.Client because the project .Net version is 4.6.2

  • Stuie Profile Picture
    Stuie 255 on at
    RE: CRM connection timeout

    Thanks. Shouldn't CrmServiceClient work though?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM connection timeout

    Hi,

    //using Microsoft.Xrm.Tooling.Connector;

    using Microsoft.PowerPlatform.Dataverse.Client;

    using System;

    using System.Net;

    public partial class c2 : System.Web.UI.Page

    {

       protected void Page_Load(object sender, EventArgs e)

       {  

           ServiceClient crmServiceClient = null;

           string sResult = "";

           string connectionString = "AuthType=OAuth;Username = info@xxxx.com;Password=xxxx;Url=xxxx.crm4.dynamics.com;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=app:/.../58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Never";

           ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

          // var service = new CrmServiceClient(connectionString);

           crmServiceClient = new ServiceClient(connectionString);

           if (crmServiceClient.IsReady)

           {

               sResult = "YES";

           }

           else

           {

               sResult = "NO";

           }

       }

    }

  • Stuie Profile Picture
    Stuie 255 on at
    RE: CRM connection timeout

    Thanks but I'm not sure how that helps.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM connection timeout

    Hi,

    just try below code and let me know if error is still there.

    ServiceClient crmServiceClient = null;

    crmServiceClient = new ServiceClient(connectionString);

    Thanks,

    Arshad

    juniorazurecrm.blogspot.com/

    juniorcrmblog.blogspot.com/

    www.youtube.com/watch

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans