Category name´╝ÜDelay

Long delay at service startup caused by WebRequest.DefaultWebProxy

Today I was resolving an issue where some of our services had a very long startup time which only occurs during booting and not at a service start/restart from the service snap-in. In other words, when I restart the service when the system is finished booting than we experience no delay.

After debugging through logging I found out that the System.Net.WebRequest.DefaultWebProxy was causing our delay of almost two minutes! The problem is that this is a property! Property access should be fast so this should have been System.Net.WebRequest.GetDefaultWebProxy().

After searching (aka. googling) it seems to be something related to WPAD which does automatic proxy server detection. I tried overriding the proxy configuration by adding the following to the app.config but without any success.

<system.net>
   <defaultProxy useDefaultCredentials=”True”>
      <proxy useSystemDefault=”False” autoDetect=”False”/>
   </defaultProxy>
</system.net>

Without retrieving the default configured .net proxy server the service starts very fast.

I guess I’m dependant on one or more services but didn’t find any except “Tcpip” and “Dnscache” and making our service dependant on these services didn’t help at all.

The conclusion is not to use “WebRequest.DefaultWebProxy” in a service as it will delay your service startup time. WebRequest.DefaultWebProxy is probably meant to be used in desktop applications.

I now created our own version of an IWebProxy locator that can be configured to use the WebRequest.DefaultWebProxy or any other implementation. For example, we have a couple or services where the settings should be saved between uninstalls, upgrades, etc. In our custom implementation we use a we use isolated storage for platform wide settings.

  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta