wcf rest starter kit HttpStageProcessingException - GetResponse timed out

Last post 06-04-2009 7:05 AM by ksirg. 2 replies.

Sort Posts:

  • wcf rest starter kit HttpStageProcessingException - GetResponse timed out

    05-20-2009, 4:10 PM
    • Member
      8 point Member
    • ksirg
    • Member since 05-08-2007, 5:18 PM
    • Posts 6

    Hi I have communication problem, I use HttpClient and send periodically (every 60 second) HttpGet message asynchronusly. But I get (to often) exception HttpStageProcessingException with message GetResponse timed out and I don't know why? The other strange thing is that when I open fiddler it starts working and this exception nerer occure

    .My code Send Message
    m_HttpClient.BeginSend(
                    new HttpRequestMessage("GET", query), new AsyncCallback(AfterUserDashboardSince), m_HttpClient);

     calback AfterUserDashboardSince looks :

     

    1    private void AfterUserDashboardSince(IAsyncResult result)
    2            {
    3                
    4                var client = result.AsyncState as HttpClient;
    5    
    6                
    7                HttpResponseMessage resp=null;
    8    
    9                try
    10               {
    11                   
    12                   using (resp = client.EndSend(result))
    13                   {
    14   
    15                       resp.EnsureStatusIsSuccessful();
    16   
    17                       
    18                       if (resp.Content.GetLength() > 2)
    19                       {
    20                           var statuses = resp.Content.ReadAsJsonDataContract<StatusesList>();
    21   
    22                          
    23                           if ((statuses.Count > 0) && (StatusesUpdated != null))
    24                           {
    25                               //rise event
    26                               StatusesUpdated(this, new StatusesLoadingEventArgs(statuses));
    27                           }
    28                       }
    29                   }
    30               }
    31               catch (ArgumentOutOfRangeException aorEx)
    32               {
    33                   //rise event
    34                   if (CommunicationError != null)
    35                   {
    36                       CommunicationError(this, new CommunicationErrorEventArgs(resp.StatusCode));
    37                   }
    38               }
    39               catch (HttpStageProcessingException timeEx)
    40               {
    41                   
    42                  //wtf
    43               }
    44               catch (Exception ex)
    45               {
    46                   //todo
    47               }
    48               
    49           }
    
     
  • Re: wcf rest starter kit HttpStageProcessingException - GetResponse timed out

    05-28-2009, 4:32 PM
    • Member
      90 point Member
    • randallt
    • Member since 02-11-2009, 4:53 PM
    • Posts 30

    It's hard to say what is happening here without more details about the server.  As a side note, if you're using this in a WinForms or WPF application, using SendAsync() and SendCompleted += handler might be easier than BeginSend.

  • Re: wcf rest starter kit HttpStageProcessingException - GetResponse timed out

    06-04-2009, 7:05 AM
    • Member
      8 point Member
    • ksirg
    • Member since 05-08-2007, 5:18 PM
    • Posts 6

     

     

    I resolve this by locking the HttpClient object, when retrive response, and it worked

     var client = result.AsyncState as HttpClient;
    HttpResponseMessage resp = null;
    try
    {
         lock (httpClientLock)
         {
              resp = client.EndSend(result);
         }
    
    //code 
    }
     
Page 1 of 1 (3 items)