Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CrmServiceClient connection to Dynamics CRM IFD fails randomly

(0) ShareShare
ReportReport
Posted on by

Hello, 

Hopefully someone can shed some light into an issue I am having trouble getting resolved. 

We have a web application that has to connect to a Dynamics CRM IFD, and it works some times... but fails to connect most of the times. When used on other CRMs, everything works perfect... we just have problems with IFD. 

I have read a lot of posts about using CrmServiceClient and I believe the error could be related to the fact that we are not holding on to an instance of CrmServiceClient. We create new ones "every once in a while". 

The constructor we are using is  Version 9 of the SDK:

CrmServiceClient(credential, authType, hostname, port, orgName, useUniqueInstance, useSsl);

And the trace log with the error shows this on creation:

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : ERROR REQUESTING ORGS FROM THE DISCOVERY SERVER
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Source	: mscorlib
Method	: HandleReturnMessage
Date	: 3/23/2018
Time	: 3:56:06 PM
Error	: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Stack Trace	: Server stack trace: 
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.Discovery.IDiscoveryService.Execute(DiscoveryRequest request)
   at Microsoft.Xrm.Sdk.Client.DiscoveryServiceProxy.Execute(DiscoveryRequest request)
   at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.DiscoverOrganizations(Uri discoveryServiceUri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials, CrmLogEntry logSink)
======================================================================================================================
Inner Exception Level 1	: 
Source	: Not Provided
Method	: Not Provided
Date	: 3/23/2018
Time	: 3:56:06 PM
Error	: ID3242: The security token could not be authenticated or authorized.
Stack Trace	: Not Provided
======================================================================================================================

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Source	: mscorlib
Method	: HandleReturnMessage
Date	: 3/23/2018
Time	: 3:56:06 PM
Error	: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Stack Trace	: Server stack trace: 
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.Discovery.IDiscoveryService.Execute(DiscoveryRequest request)
   at Microsoft.Xrm.Sdk.Client.DiscoveryServiceProxy.Execute(DiscoveryRequest request)
   at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.DiscoverOrganizations(Uri discoveryServiceUri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials, CrmLogEntry logSink)
   at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.InitCRM2011Service()
======================================================================================================================
Inner Exception Level 1	: 
Source	: Not Provided
Method	: Not Provided
Date	: 3/23/2018
Time	: 3:56:06 PM
Error	: ID3242: The security token could not be authenticated or authorized.
Stack Trace	: Not Provided
======================================================================================================================

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM


Any thoughts will be very appreciated!

thanks

*This post is locked for comments

  • alx.kpk Profile Picture
    21 on at
    RE: CrmServiceClient connection to Dynamics CRM IFD fails randomly

    Any new on this?

  • Community Member Profile Picture
    on at
    RE: CrmServiceClient connection to Dynamics CRM IFD fails randomly

    Hi Temmy,

    actually we have been setting useUniqueInstance to True since day 1... and still this is a problem.

    thanks for your reply.

  • Community Member Profile Picture
    on at
    RE: CrmServiceClient connection to Dynamics CRM IFD fails randomly

    Thanks Nico, I will try this today and see if something shows up there.

    I am concerned about the intermittence of the problem though.. it feels odd to me.

  • Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: CrmServiceClient connection to Dynamics CRM IFD fails randomly

    Hi,

    CrmServiceClient(credential, authType, hostname, port, orgName, useUniqueInstance, useSsl);

    The default for useUniqueInstance is false. Set it true and check weather it's works normal or not.

    Usually when people create IOrganizationService, they use static variable so when another instance running, it will get from same variable. But for me it's not good. Better using local variable instead of global static variable.

  • Suggested answer
    NicksTuk Profile Picture
    1,833 on at
    RE: CrmServiceClient connection to Dynamics CRM IFD fails randomly

    Check for errors on the token issuing server. This could be an AD FS issue.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans