WaelHamze / dyn365-ce-vsts-tasks

VSTS Extension for Dynamics 365 Customer Engagement
https://marketplace.visualstudio.com/items?itemName=WaelHamze.xrm-ci-framework-build-tasks
GNU General Public License v3.0
115 stars 54 forks source link

Publish Customizations always times out #226

Open Shikha1405 opened 3 years ago

Shikha1405 commented 3 years ago

Publish Customizations action always times out.

I have set the timeout property as 1200 sec but there is no response and pipeline fails.

If I check publish history in CRM environment, Publish all operation is triggered and completes in 8 mins but pipeline gets stuck, waits for 1200 sec and throws below error: #

[error]The request channel timed out while waiting for a reply after 00:20:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

Any help?

sannicolao commented 3 years ago

@Shikha1405 To fix this issue, we created a custom task.

    try
    {
       $request = New-Object Microsoft.Crm.Sdk.Messages.PublishAllXmlRequest
       $response = $CRMConn.ExecuteCrmOrganizationRequest($request, $null) 

       Write-Verbose 'publish Job started...' 

       $fetch = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="msdyn_solutionhistory">
    <attribute name="msdyn_name" />
    <attribute name="msdyn_status" />
    <attribute name="msdyn_starttime" />
    <attribute name="msdyn_result" />
    <attribute name="msdyn_operation" />
    <attribute name="msdyn_errorcode" />
    <attribute name="msdyn_endtime" />
    <attribute name="msdyn_solutionhistoryid" />
    <order attribute="msdyn_starttime" descending="true" />
    <filter type="and">
      <condition attribute="msdyn_operation" operator="in">
        <value>3</value>
        <value>4</value>
      </condition>
      <condition attribute="msdyn_status" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>'

        $publishing = $true

        while($publishing)
        {
            Start-Sleep -Seconds 15

            $activeJobs = Get-XrmEntities -ConnectionString $crmConnectionString -FetchXml $fetch

            if ($activeJobs.Count -eq 0)
            {
                $publishing = $false
                Write-Verbose 'publish Job done...' 
            }
            else
            {
                Write-Verbose 'publish Job runing...' 
            }
        }

    }
    catch
    {
        throw $CRMConn.LastCrmException
    }

@WaelHamze : Probably you can us it as well? 😄

arvidpm commented 3 years ago

This issue still persists. Our "solution" was to lower the timeout limit to 10 minutes, since we checked that our publishes were 6-9 minutes. We could then try another publish after the timeout which finishes in ~40 secs and sends a response.

HansMeiser999 commented 3 years ago

I also encounter this issue and it is very annoying. After deploying 20+ solutions in a release it just not shows green due to this error. No matter what I configure (0, 30, 300) the command runs into a timout after exactly 10 minutes. I cannot use the custom task above as we have to use Service Connections and not connection strings. Sadly most of the times the publish all command takes more than 10 minutes.

Shikha1405 commented 2 years ago

Anyone who got the resolution?

hansgfixed commented 2 years ago

Issue still persists.

WaelHamze commented 2 years ago

@Shikha1405 @hansgfixed I had this issue and it got resolved after increasing the timeout in the task. In your case does the publish take less than timeout specified but the task still fails? Are you running on hosted or private agents?

WaelHamze commented 2 years ago

@sannicolao isn't the first publish call that you make in the code that you shared a sync call? (i.e. the execution will be blocked until this call succeeds or fails)

hansgfixed commented 2 years ago

@Shikha1405 @hansgfixed I had this issue and it got resolved after increasing the timeout in the task. In your case does the publish take less than timeout specified but the task still fails? Are you running on hosted or private agents?

We're running the task on a private agent and increasing the timeout doesn't help. Any idea? We now set a time out for about 10 minutes and continue on error to avoid letting the publish task take hours.