Silverlight Search AP Client - Failures and Incredibly Poor Response Times

Answered Silverlight Search AP Client - Failures and Incredibly Poor Response Times

  • Wednesday, August 08, 2012 10:17 PM
     
      Has Code

    Azure Bing Search Support Team,

    I'm pretty frustrated with the Azure Bing Search API testing I've done from my Silverlight app. Pretty much used the version shown in the Migration Guide as seen below:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Data.Services.Client;
    
    namespace BingAPI
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                var bingContainer = new Bing.BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search/"));
    
                // replace this value with your account key
                var accountKey = "My account key inserted here";
    
                // the next two lines configure the bingContainer to use your credentials.
                bingContainer.Credentials = new NetworkCredential(accountKey, accountKey);
    
                // note, this line was not required for the C# console app
                bingContainer.UseDefaultCredentials = false;
    
                // the next two lines define the request for data and 
                var Query = bingContainer.Web("newfoundland", null, null, null, null, null, null, null);
    
                Query.BeginExecute(new AsyncCallback(
                    delegate(IAsyncResult ar)
                    {
                        var QueryResult = (DataServiceQuery<Bing.WebResult>)ar.AsyncState;
                        var Results = QueryResult.EndExecute(ar);
                        var resultsList = Results.ToList();
    
                        foreach (var result in resultsList)
                        {
                            // do something with the result, or bind the result
                        }
                    }), Query);
            }
        }
    }
    

    Garden variety Silverlight. But:

    1. More than 90% of first time searches time-out with a DataServiceExceptionQuery after 20 to 30 secs.

    2. After than first time query, subsequent queries using the same search term work albeit with very poor response times.

    What's going on? If there's something I can do to improve my SL App please let me know. I migrated from Bing API 2.0 for my commericial product, and frankly, right now would not release a version with the Azure API based on what I've seen so far.

    Help!!

    Clyde

All Replies

  • Thursday, August 09, 2012 7:52 AM
    Moderator
     
     Answered

    Hi Clyde,

    Try to use Fiddler to monitor the requests. This helps to check if the time is spent in requesting service or something else. Fiddler allows you to check the actual response time. You can also use Fiddler or the browser to access the same API. If that also works very slow, it may be a network environment issue.

    BR,

    Arwind


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

  • Thursday, August 09, 2012 4:14 PM
    Owner
     
     

    Hi Clyde,

    Generally speaking, what you describe seems to be attributable to your network environment and not Silverlight code. Is your application behind some sort of proxy or firewall? Also, what is your geographic location?

    Thanks,

    Max


  • Thursday, August 09, 2012 8:51 PM
     
     Answered Has Code

    Hi Clyde,

    If you are still experiencing the failure or slow response, you can add following line in your code. With a unique user agent, we can identify your request on our side.

    ts.SendingRequest += (sender, args) => args.Request.Headers.Add(HttpRequestHeader.UserAgent, "3FC700E4-6AFA-48D2-9D1A-AE97E9FC3C1C");
    

  • Tuesday, August 14, 2012 6:09 PM
     
     

    Vincent, Arwind,


    Thank you for your responses. I'm running the SL app from a VM and I never had a problem accessing Bing Search using the Bing 2.0 API.

    It may be b network environment but something has changed with the Azure migration.

    Thanks,

    Clyde