Intermittent Exceptions

Oct 23, 2011 at 10:48 AM

Hi,

I've had rather strange behaviour whilst using LinqToTwitter! Without changing the code, I sometimes get an exception.

After authorizing (as in the demo), I run a query which sometimes gives me an exception. Here is my code:

            // start the authorization process (launches Twitter authorization page).

          auth.Authorize();

            using (var twitterCtx = new TwitterContext(auth, "https://api.twitter.com/1/", "https://search.twitter.com/")) 

          {

                //Log

                twitterCtx.Log = Console.Out;
                #region Demos
                //

                // Each Run section below will execute at least one demo

                // from the specified area of the Twitter API.

                // Uncomment and navigate to code to see the example.

                //

                // LINQ to Twitter documentation "Making API Calls" is here:

                //  http://linqtotwitter.codeplex.com/wikipage?title=Making%20API%20Calls&referringTitle=Documentation

                //

                // Each section supports the Twitter API, as documented here:

                //  http://dev.twitter.com/doc

                //

               //Get the user for MyUserName

                var l_Caz = (from user in twitterCtx.User

                                     where user.Type == UserType.Show &&

                                          user.ID == "MyUserName"

                                    select user).First();

 

I sometimes get a WebException cause by an asyncException in resetEvent.WaitOne() in the function public string QueryTwitter<T>(Request request, IRequestProcessor<T> reqProc)  in TwitterExecute.cs. The exception is:

{System.Net.WebException: The remote server returned an error: (400) Bad Request.   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)   at LinqToTwitter.TwitterExecute.<>c__DisplayClass8`1.<QueryTwitter>b__5(IAsyncResult ar) in C:\LinqToTwitterSource_20110711\LinqToTwitter\LinqToTwitterAg\LinqToTwitter\TwitterExecute.cs:line 354}

Here is the call stack:

LinqToTwitter.dll!LinqToTwitter.TwitterExecute.QueryTwitter<LinqToTwitter.User>(LinqToTwitter.Request request, LinqToTwitter.IRequestProcessor<LinqToTwitter.User> reqProc) Line 379 + 0x8 bytes C#  LinqToTwitter.dll!LinqToTwitter.TwitterContext.Execute<LinqToTwitter.User>(System.Linq.Expressions.Expression expression, bool isEnumerable) Line 807 + 0x64 bytes C# 

[External Code]  

 LinqToTwitter.dll!LinqToTwitter.TwitterQueryProvider.Execute<LinqToTwitter.User>(System.Linq.Expressions.Expression expression) Line 110 + 0x94 bytes C# 

 [External Code]  

 LinqToTwitterDemo.exe!LinqToTwitterDemo.Program.Main() Line 122 + 0x340 bytes C#

 

When I don't get the exception there, I go through the 1000 people MyUserName follows and check that they follow me using the code:

           var friendship =                         (from friend in m_Ctx.Friendship 

                        where friend.Type == FriendshipType.Show && 

                              friend.SourceScreenName == p_Person.ScreenName() && 

                              friend.TargetScreenName == ScreenName() 

                        select friend).First();

where I sometimes get this exception (with different friends).

 

Any idea what might be causing these exceptions?

Thank you.

Coordinator
Oct 24, 2011 at 2:50 PM

Hi,

I'm not sure what that is.  If it can be reliably reproduced, I could follow up and debug it.  I'll make it a work-item so I'll remember to revisit to see what's happening.  In the meantime the best strategy for handling this situation might be to do some exception handling, logging, and possible retries in case it's a temporary glitch.  If you learn more, you're welcome to attach more notes to the work-item.

Joe

Coordinator
Oct 24, 2011 at 2:51 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 24, 2011 at 3:31 PM

Thank you Joe!