Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect-CrmOnline - intermittent connection failure #520

Open
ryan950ng opened this issue Mar 27, 2023 · 2 comments
Open

Connect-CrmOnline - intermittent connection failure #520

ryan950ng opened this issue Mar 27, 2023 · 2 comments

Comments

@ryan950ng
Copy link

ryan950ng commented Mar 27, 2023

Hi,

I am using the Connect-CrmOnline to connect to the server in my Gitlab pipeline, but the connection will fail intermittently.
Sometimes it works after a few retry.

    Import-Module Microsoft.Xrm.Data.PowerShell
    Set-CrmConnectionTimeout -TimeoutInSeconds 600
    $conn.OrganizationWebProxyClient.Endpoint.Binding.SendTimeout.TotalMinutes
    
    Connect-CrmOnline -ConnectionTimeoutInSeconds 600 -ClientSecret $oAuthClientSecret -OAuthClientId $oAuthClientId -ServerUrl $CRMDestinationUrl

This is the error returned:

WARNING: Please reconnect to the service after setting the connection timeout or the new timeout will *not* be used for
 operations.
IsReady                             : False
IsBatchOperationsAvailable          : False
MaxRetryCount                       : 10
RetryPauseTime                      : 00:00:05
Authority                           : 
ActiveAuthenticationType            : ClientSecret
OAuthUserId                         : 
TenantId                            : 00000000-0000-0000-0000-000000000000
EnvironmentId                       : 
ConnectedOrgId                      : 00000000-0000-0000-0000-000000000000
CrmConnectOrgUriActual              : https://[Masked]/XRMServices/2011/Organization.svc
ConnectedOrgFriendlyName            : 
ConnectedOrgUniqueName              : 
ConnectedOrgVersion                 : 
SdkVersionProperty                  : 9.2.47.9489
CallerId                            : 00000000-0000-0000-0000-000000000000
CallerAADObjectId                   : 
DisableCrossThreadSafeties          : False
SessionTrackingId                   : 
ForceServerMetadataCacheConsistency : False
LastCrmError                        : One or more errors occurred. => An error occurred while sending the request. => 
                                      Unable to connect to the remote server => A connection attempt failed because 
                                      the connected party did not properly respond after a period of time, or 
                                      established connection failed because connected host has failed to respond 
                                      40.119.215.132:443ERROR REQUESTING Token FROM THE Authentication context - 
                                      General ADAL Error
                                      One or more errors occurred. => An error occurred while sending the request. => 
                                      Unable to connect to the remote server => A connection attempt failed because 
                                      the connected party did not properly respond after a period of time, or 
                                      established connection failed because connected host has failed to respond 
                                      40.119.215.132:443One or more errors occurred. => An error occurred while 
                                      sending the request. => Unable to connect to the remote server => A connection 
                                      attempt failed because the connected party did not properly respond after a 
                                      period of time, or established connection failed because connected host has 
                                      failed to respond 40.119.215.132:443Unable to connect to CRM: An error occurred 
                                      while sending the request.
                                      One or more errors occurred. => An error occurred while sending the request. => 
                                      Unable to connect to the remote server => A connection attempt failed because 
                                      the connected party did not properly respond after a period of time, or 
                                      established connection failed because connected host has failed to respond 
                                      40.119.215.132:443Unable to Login to Dynamics CRM
                                      Unable to Login to Dynamics CRMOrganizationWebProxyClient is null
                                      OrganizationWebProxyClient is null
An error has occurred: One or more errors occurred. => An error occurred while sending the request. => Unable to connect to the remote server => A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.119.215.132:443ERROR REQUESTING Token FROM THE Authentication context - General ADAL Error
One or more errors occurred. => An error occurred while sending the request. => Unable to connect to the remote server => A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.119.215.132:443One or more errors occurred. => An error occurred while sending the request. => Unable to connect to the remote server => A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.119.215.132:443Unable to connect to CRM: An error occurred while sending the request.
One or more errors occurred. => An error occurred while sending the request. => Unable to connect to the remote server => A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.119.215.132:443Unable to Login to Dynamics CRM
Unable to Login to Dynamics CRMOrganizationWebProxyClient is null
OrganizationWebProxyClient is null************ NullReferenceException - ExecuteAsync : AsyncImportRequest |=> Object reference not set to an instance of an object.
Object reference not set to an instance of an object.[TerminalFailure] Failed to Execute Command - ExecuteAsync : RequestID=[Masked] : AsyncImportRequest duration=00:00:00.0117927 ExceptionMessage = Object reference not set to an instance of an object.
Object reference not set to an instance of an object.

The confusing part is due to the intermittent failure, and I have tried timeout and it's still having the same error.

@seanmcne
Copy link
Owner

seanmcne commented Mar 28, 2023

It looks to be an error stating the request to acquire an auth token failed due to a timeout - you could use a try/catch to retry the connection on a failure to acquire an auth token.

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.119.215.132:443 ERROR REQUESTING Token FROM THE Authentication context - General ADAL Error One or more errors occurred.

@ryan950ng
Copy link
Author

Few things that I have tried:

  • try catch but unable to catch the failure
  • retry on the pipeline, continue to fail
  • ping the server before connecting, if the ping fails the connection fails too
  • sleep for 30s before running the connection

None of the method is working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants