web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    NicksTuk Profile Picture
    1,833 on at

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

  • Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    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.

  • Community Member Profile Picture
    on at

    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.

  • Community Member Profile Picture
    on at

    Hi Temmy,

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

    thanks for your reply.

  • alx.kpk Profile Picture
    35 on at

    Any new on this?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans