SBX - Search With Button

SBX - Forum Post Title

dynamics 365 crm plugin time out issue

Microsoft Dynamics CRM Forum

Dynamics 365 CRM asked a question on 6 May 2019 10:58 AM

Question Status

Suggested Answer

Hi,

I have a synchronous plugin registered on a create of custom entity.That custom entity record gets created from other external system(they are connecting to CRM organization service and creating record. This record holds a json string ). Once the above record gets created, my plugin gets triggerred and read through json object and updates opportunities.

The whole above mentioned process works perfectly fine in DEV. But in UAT it's throwing plugin 2 mints max time out error. The json string has 1200 records ( i don't think it's big number). Also, when I just push a json string having 1 record to UAT, it works fine.

My doubt is , why UAT instance getting time out ? why not in DEV ? Why UAT organization service responding very slowly ?

Can I increase plugin time out using ( crmServiceProxy.Timeout = new TimeSpan(0, 5, 0) ) ? The only other option I have is custom workflow ? Does the custom work works fine in Online version without any time out issue ?

Thanks In advance !!

Reply
Suggested Answer

Hi,

There is no supported way to increase timeout for plugin   ,Slowness issue  could be for many reason. You can raisec ticket to MS for that.

However for safe side I would recommend to go for custom workflow activity to avoid timeout issue.

Reply
Dynamics Objects 365 responded on 6 May 2019 12:36 PM
My Badges
Suggested Answer

If your plugin is timing out then most probably you are doing it wrong or not following the best practices.

Change your plugin step to PostCreate - Asynchronous.

Ideally you should go ahead with Synchronous only if it completes in under 3-4 seconds. Not more than that.

Reason why your plugin would have worked in Dev and not in UAT: Generally, data in Dev is very small compared to UAT instances.

Another solution which I can think for your scenario is Microsoft Flow. It is totally No-Code solution. you can trigger the flow on Create of the entity , retrieve the Required Opportunities and loop through them and Update them.

Try it out here https://flow.microsoft.com

Please provide your feedback if this answer solved any of your problem or gave you any direction.

Reply
Jim Daly responded on 6 May 2019 2:23 PM
My Badges

If you want to know more about this particular plug-in and how it is working, you can to instrument you plugin code and add timestamps for each record processed. 

Use the tracing feature described here: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/logging-tracing

Then after the plugin fails with 2 min timeout you can see the logs in plugin traces (which you will have to enable to log ‘all’ data) and figure out where the time is spent.  The update of opportunity could be firing more plugins downstream so those will add up to the time.   All this you can figure out by instrumenting plugins as a first step.

As called out by others, some operations shouldn't be done synchronously. Although the timeout is 2 minutes, you really shouldn't consider a synchronous plug-in that can't complete in a matter of seconds. You have to share that timeout period with every other timeout that is registered for that event AND all the other subsequent synchronous plug-ins that could be triggered by your code. There are some things you shouldn't attempt with synchronous plug-ins.

More information: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/scalable-customization-design/overview

Reply
Suggested Answer

Hi

On top of what others suggested, I would recommend you check your code, it could be that your code is accessing some URL to perform actions and if for some reason if the HTTP client does not timeout before plugin does, you migt get this error. In other words, your plugin code might be trying to access some service but the URL is invalid or the service it's accessing taking longer than plugin timeout time.

One other possibility is that if there are any infinite loops in your code or delay or Thread.Sleep steps, it might be taking longer as well.

Reply
Ravi Kashyap responded on 7 May 2019 1:18 AM

Hi,

Create multiple records within the plugin (Synchronous) is never a good idea. You never know in future if the same plugin will continue to work as the number of records to be created will increase so is the size of the current database which will impact the retrieval of records as well.

These type of requirements are best to be achieved by using either any of the third party tool like scribe which contiguously pulls the data or by writing your own scheduler.

Hope this helps.

Reply
Dynamics365 Rocker responded on 7 May 2019 7:24 AM
My Badges
Suggested Answer

Json is a Async operation. It is better to move to workflow Activity.

Reply
Suggested Answer

Hi,

There is no supported way to increase timeout for plugin   ,Slowness issue  could be for many reason. You can raisec ticket to MS for that.

However for safe side I would recommend to go for custom workflow activity to avoid timeout issue.

Reply
Dynamics Objects 365 responded on 6 May 2019 12:36 PM
My Badges
Suggested Answer

If your plugin is timing out then most probably you are doing it wrong or not following the best practices.

Change your plugin step to PostCreate - Asynchronous.

Ideally you should go ahead with Synchronous only if it completes in under 3-4 seconds. Not more than that.

Reason why your plugin would have worked in Dev and not in UAT: Generally, data in Dev is very small compared to UAT instances.

Another solution which I can think for your scenario is Microsoft Flow. It is totally No-Code solution. you can trigger the flow on Create of the entity , retrieve the Required Opportunities and loop through them and Update them.

Try it out here https://flow.microsoft.com

Please provide your feedback if this answer solved any of your problem or gave you any direction.

Reply
Suggested Answer

Hi

On top of what others suggested, I would recommend you check your code, it could be that your code is accessing some URL to perform actions and if for some reason if the HTTP client does not timeout before plugin does, you migt get this error. In other words, your plugin code might be trying to access some service but the URL is invalid or the service it's accessing taking longer than plugin timeout time.

One other possibility is that if there are any infinite loops in your code or delay or Thread.Sleep steps, it might be taking longer as well.

Reply
Dynamics365 Rocker responded on 7 May 2019 7:24 AM
My Badges
Suggested Answer

Json is a Async operation. It is better to move to workflow Activity.

Reply

SBX - Two Col Forum

SBX - Migrated JS