locked
SDK WebClientPlugin is very slow RRS feed

  • Question

  • I need a plugin which executes a httpwebrequest and found an example in the SDK. ( WebClientPlugin.cs )

    If I use this sample plugin I recognized that it is very slow. The first 5 time I execute the plugin( I registered it synchronal on the create of the account) it takes more than 5 seconds in an CRM online organization until the plugin has finished and the record is saved. I put in some tracing and found out that the plugin is fired very quickly but only the downloaddata is very slow. I tried to use different web pages to go sure that the webpage is not the bottle neck.

    It would be great if someone has an idea why this is that slow in an online environment. The same code only takes 200 ms in an winforms application.

    The code looks straight forward :

       

    using (WebClient client = newWebClient())                 {                     byte[] responseBytes = client.DownloadData(_webAddress);                     string response = Encoding.UTF8.GetString(responseBytes);                     //</snippetWebClientPlugin2>                     tracingService.Trace(response.Substring(0, 250));                     // For demonstration purposes, throw an exception so that the response// is shown in the trace dialog of the Microsoft Dynamics CRM user interface.                 } 

    Does someone have an idea why it is that slow to download the data.

    thx

     

    Friday, November 29, 2013 8:24 AM

All replies

  • If using Crm Online, the request comes from the Microsoft CRM server. One possible cause for the delay is low latency from the Microsoft data centre to the web address that you're accessing. Another possibility is that Microsoft throttle outgoing requests or prioritise other traffic. And a third possiblility is that there are additional security checks around the instantiation of the WebClient class. If you add further trace lines, and write the time at each step, you should be able to determin if the delay is when accessing the file, or when instantiating the WebClient.

    However, whatever the cause is, I can't see any way to improve it. If possible, I'd suggest registering the plugin to run asynchronously, so that the user sees no delay


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, November 29, 2013 6:28 PM
    Moderator
  • As described the download takes long and the same code works always fast when runnning it locally from my machine. 
    Running asynchronously is also not the best way as I want to trigger an action with this request and want to write the result into CRM.

    thx 

    Monday, December 2, 2013 8:08 AM