[EWS/C#] The request failed. The operation has timed out RRS feed

  • Question

  • I have a public folder which contains around 8000 Contact Items. I am trying to read more than 1000 contact items based of some filter criteria using EWS API. But I am getting below error while performing read operation:


    The request failed. The operation has timed out-->   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(HttpWebRequest& request)

       at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()

       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()

       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalLoadPropertiesForItems(IEnumerable`1 items, PropertySet propertySet, ServiceErrorHandling errorHandling)

       at Microsoft.Exchange.WebServices.Data.ExchangeService.LoadPropertiesForItems(IEnumerable`1 items, PropertySet propertySet)


    I have set the timeout property of ExchangeService as  15 min(in msec) but still it is failing after 100 sec, which is the default timeout period for EWS.


    I am using EWS 1.1.


    Please help me in resolving this error.


    Friday, March 11, 2011 2:37 PM

All replies

  • A few things i would suggest is first make sure your use paging and i wouldn't page more then 1000 objects at a time. If your using a search filter what is the searchfilter your using ? Have you tried it without the searchfilter do you get the timeout ?


    Tuesday, March 15, 2011 2:27 AM
  • Actually, the request is not getting timed out while searching. It is getting timed out when we are trying to load one of the custom property for all the searched contacts. Also, my question is why the ExchangeService.Timeout property is not getting reflected. Despite of setting it to 15 minutes or more the request is getting timed out in its default time i.e. 100 sec.   


    We are following these steps

    1.       Prepare the search criteria

          //Searech Filter Collection for sDate and eDate

          List<SearchFilter> searchFilterCollection = new List<SearchFilter>();

         if (startDate != null)


              SearchFilter sfFrom = new SearchFilter.IsGreaterThanOrEqualTo(ContactSchema.DateTimeCreated, startDate);




          SearchFilter sfTo = new SearchFilter.IsLessThan(ContactSchema.DateTimeCreated, endDate);



          List<SearchFilter> cmsidSearchFilterCollection = new List<SearchFilter>();

          CMSExtendedPropertyDefintions cmsExtdProps = new CMSExtendedPropertyDefintions();

          SearchFilter sfzUniqueId = new SearchFilter.ContainsSubstring(cmsExtdProps.zCMSIDPropDef, "C");

          SearchFilter sfzUniqueIdnot = new SearchFilter.Not(sfzUniqueId);



    SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, searchFilterCollection.ToArray());


    2.       Get only the firstclassproperties for the searched items with a search criteria resulting into more that 1000 results. I understand that we should have used paging here but the request is not getting timed out here.


          ItemView view = new ItemView(Int32.MaxValue);

          view.OrderBy.Add(ContactSchema.DateTimeCreated, SortDirection.Ascending);

    view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);

    // We have not used paging but request is not getting timed out here.

    FindItemsResults<Item> foundItems = this.ExchangeService.FindItems(folderId, searchFilter, view);


    3.       Load the property  “ID” for all the searched contacts. We are using link Q query here. The request is getting timed out for this call.


          PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties) { };

          propertySet.RequestedBodyType = BodyType.HTML;


          propertySet.Add(ContactSchema.Id); // CMSUniqueId i.e. Exchange UniqueId


          if (foundItems.Items.Count > 0)


            // this is the statement where the timeout is occuring.        

            this.ExchangeService.LoadPropertiesForItems(from Item item in foundItems select item, propertySet);

             foreach (Item item in foundItems.Items)





    Tuesday, March 15, 2011 6:58 AM
  • Okay firstly what version of Exchange are you using ?

    Setting the ExchangeService to 15 minutes wont really have an impact as EWS won't exceed IIS default setting which is 100 seconds. 

    2. You should always use paging doesn't matter if you query didn't timeout (as it may start in the future) see

    3. This is a large batch operation where your trying to pull the body of the contact and all to properties ? This could be very large amount of data depending on what you have stored in there. if you implement paging and fiddle with optimal page size which will be under 1000 and also reduce the properties your retrieving down to those you actually using this should help solve the problem and increase the performance of your application.

    Wednesday, March 16, 2011 2:52 AM