nav-left cat-right
cat-right

Silverlight – HTTP request to [Url] was abor...

If you are developing a Silverlight application that connects to a WCF service, you may have received the following error:

The HTTP request to ‘http://localhost:2997/SomeService.svc’ was aborted.  This may be due to the local channel being closed while the request was still in progress.  If this behavior is not desired, then update your code so that it does not close the channel while request operations are still in progress.

This error generally happens when a request on the server takes longer than allowed. To remedy this, you can set four properties across two .config files. I will first explain the four properties. Then, I will detail the two configuration files involved.

Configuration Properties

The four properties that you need to set are called: openTimeout, closeTimeout, receiveTimeout, sendTimeout. These properties are defined as follows:

  1. openTimeout – A TimeSpan that details how long an operation can remain open.
  2. closeTimeout – A TimeSpan that signals how long an operation has to close.
  3. receiveTimeout – A TimeSpan that represents how long a receive operation has to complete.
  4. sendTimeout – A TimeSpan that details how long a send operation has to complete.

More specifics can be found here. Regardless, because each of these properties are TimeSpan elements, you can set the timeouts to whatever granularity you find acceptable. If you are not interested in going into that level of detail, you can set them all to the same value. If you are experiencing the error that is the subject of this post, set each of these values to higher value than the default. The default value is a measly one minute. If you’re operation takes longer than one minute, you may choose to up the default values to five minutes as a test, or even higher if need be. An example configuration that sets the timeouts to five minutes  is shown here:

<binding name="CustomBinding_MyService" closeTimeout="00:05:00" openTimeout="00:5:00" receiveTimeout="00:05:00" sendTimeout="00:05:00">
  <binaryMessageEncoding />
  <httpTransport>
    <extendedProtectionPolicy policyEnforcement="Never" />
  </httpTransport>
</binding>

As shown above, the four properties detailed earlier can be configured on a Binding element in your config file.  In the world of Silverlight though, it is important to set these property values in two configuration files.

The Two Configuration Files

Silverlight applications will often times have a web.config file on the server-side. On the client-side there is a ServiceReferences.clientConfig file that will also need to be updated. One common mistake is just adding the timeout configurations on the server-side web.config file and not adding them on the client side. Because of this, please make sure that you set the configuration values on both the server, and client side. And for the sake of sanity, it is recommended that you set them to the same value :) .

If you would like to learn more about Silverlight, I recommend the book Silverlight in Action. I hope you found this post valuable.

Windows Phone 7 Icons...

In mid-March 2010, Microsoft unveiled Windows Phone 7 to the world. In late March 2010, Microsoft made some of the icons associated with Phone UI available here.

This package includes three different versions of the icons: light, dark, and vector. Each version provides 32 of the core icons used throughout the Windows Phone 7 UI.  These provide a great way to prototype the mobile applications you want to deliver to the world.