Friday, March 6, 2015

WCF Client App Optimization using FiddlerCore SDK / Help Fiddler Fixes my app but I don't know how? / FiddlerCore SDK integration with WPF application

06 March 2015



I have recently been working on a Data Analysis and Reporting application that was making many calls to its back-end WCF service because of its nature. The application expanded with time, and by the time all the features and reports were added it was taking 10-40 seconds between each view switch/tab change etc. I was using one client proxy across the entire application. 




I ran fiddler to analyse what was going on, and I found that the application works well while fiddler is running. but not other wise. I did some research and found this article:

http://blogs.telerik.com/fiddler/posts/13-02-28/help!-running-fiddler-fixes-my-app-

I followed the suggestion in the app and did some research to adjusted some configuration but it wasn't very helpful. Since the application has to go into production soon, I had to come up with a quick solution to fix this problem. 

I decided to integrate fiddler with in the app using Fiddler SDK a.k.a FidderCore.  Steps:


  • Created a folder 3rdParty in my SolutionFolder

  • Copied FiddlerCore Dlls (.net 4) to SolutionFolder\3rdParty. Added references to FiddlerCore.dll to my WPF application.

  • Handled ApplicationStartUp Event in WPF application (You can use Program.cs file in Winforms app):

            Fiddler.CONFIG.IgnoreServerCertErrors = false;
FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

           FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);

            int iPort = 8877;
            Fiddler.FiddlerApplication.Startup(iPort, oFCSF);

  • Handled ApplicationExit Event
Fiddler.FiddlerApplication.Shutdown();
  • Adjusted the app.config binding file as follow:
... useDefaultWebProxy="false" proxyAddress="http://127.0.0.1:8877" ... 
And that's it! The application works 10x times faster now. Leave a thumbs up if this article helps you. 

Basit

No comments:

Post a Comment