From time to time starting since 20 of February when we try to get emails from office 365 using ews the connection is blocked

We keep getting the following error when we try through ews to get emails from different exchange mailboxes. As soon as we restart the application, or even without restarting it sometimes everything gets back to normal. 

The request failed. The underlying connection was closed: An unexpected error occurred on a send.   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)

   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
   at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, SearchFilter searchFilter, ViewBase view)

We have in total 25 threads. On Each thread we get messages from a certain number of mailboxes (between 5 and 25 ).

We try to get the emails since the last email received. Every minute we make a new request to get emails for all the mailboxes interrogated on a certain thread. Sometimes it takes more than one minute to query all the mailboxes associated to one thread. If this is happening than the next request comes immediately after.

 

Each time before requesting for new emails we create a new ExchangeService object in the following way:

  this.exchangeService = new ExchangeService(connectionInfo.ExchangeVersion);

 this.exchangeService.Credentials = new NetworkCredential(connectionInfo.User, connectionInfo.Password, connectionInfo.Domain);

  this.exchangeService.Url = new Uri(connInfo.Url);

  this.exchangeService.Timeout = 300000; // 5 min           

  this.exchangeService.TraceListener = new ExchangeTraceListener();

  this.exchangeService.TraceFlags = TraceFlags.EwsRequest | TraceFlags.EwsResponse; // trace both request and response

  this.exchangeService.TraceEnabled = true;

 //Connections with same Group name are processed in one thread

  if (!Guid.Empty.Equals(connectionGroupName)) exchangeService.ConnectionGroupName = connectionGroupName.ToString();

 

For each thread we have a distinct ConnectionGroupName.

 

Once The exchangeservice object is created we get all the items received at the exchange side since the last email was picked up.

 

 

ItemView iview = new ItemView(synchronizedCount);

iview.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.DateTimeReceived);

iview.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Ascending);

FindItemsResults<Item> findResults = exchangeService.FindItems(xsFolder.XsFolderId, new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived,startDateTime),iview);

 

For each item in the list we load the following properties:

 

PropertySet propertySet = new PropertySet();

propertySet.Add(ItemSchema.MimeContent);

propertySet.Add(ItemSchema.DateTimeReceived);

propertySet.Add(ItemSchema.HasAttachments);

exchangeService.LoadPropertiesForItems(itemList, propertySet);

 

If you need any other information or clarification please let me know.

 

Thank you.

We would like to get concrete help in solving the problem. If for this is necessary to pay is fine for us. Just please inform us how we should proceed. 

March 27th, 2015 2:35pm

If you're looking for formal support, you can find contact information at http://support.microsoft.com/oas. Offhand it sounds like you might be getting throttled, in which case it is proper to back off and try again after a time.
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2015 10:49am

I don't see there anything related to Office 365. Should I use "Microsoft Exchange Server 2013"?. I want to mention that we have still an open case with Office 365 support. Our problem is that we have checked if we are hitting any limitation in the throttling policy and it seems not. That 's why we need somehow to have a clear answer where is the problem and how to adapt the application in order to avoid these problems and bypass the limitations. We have this application running without problems for the past 3 years so just out of the blue without changing anything this error started. The application is running at several customers towards office 365 or local exchange servers(we have thousands of exchange mailboxes to which we connect at different customers).

Thank you.

March 31st, 2015 12:59pm

Exchange 2013 should point you in the right direction. Be sure to pick a problem type of "Developer". You definitely want to be talking with Developer Support on this one.
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2015 3:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics