locked
Exchange Web Service hangs with no exceptions. Too many calls? RRS feed

  • Question

  • I'm developing a C# WinForms application to fetch emails and appointments from a users mailbox in Office 365. I'm using the EWS Managed API 2.2 and have created a class for all my EWS related methods.

    For each method I'm using a new instance of the ExchangeService class  to do various functions, starting out with getting the last 500 pages of emails and all appointments of the current day from the mailbox and afterwards adding, deleting and modifying objects as they get in through a streaming subscription.

    The issue I'm having is, that whenever I make a larger amount of calls, ex. Setting the FlagStatus of 20 emails, all further EWS calls will stop processing without throwing any exception. Everything is run in backgroundworkers and tasks so the UI thread is still responsive but I don't get any results back from my methods.

    Am I hitting some sort of limit?

    I tried building a very simple locking method (below) by calling start and stop before and after each call is made but that doesn't seem to help.

    public static void WaitForEWSCall(string action)
    {
        switch (action)
        {
            case "start":
                while (ewsCallInProgress)
                {
                    Thread.Sleep(1000);
                }
                ewsCallInProgress = true;
                break;
            case "stop":
                ewsCallInProgress = false;
                break;
        }
    }


    • Edited by Dawol Monday, June 19, 2017 2:48 PM wrong subscription type
    Monday, June 19, 2017 2:47 PM

All replies

  • The two things i could think that may cause this is you maybe breaching the throttling limit for concurrent connections to Exchange https://msdn.microsoft.com/en-us/library/office/jj945066(v=exchg.150).aspx (this is 27 by default).

    The other one is are you certain you have raised the default connection limit in .NET this is 2 by default so you will need to set this higher if you want to make more the 2 concurrent connections eg

     System.Net.ServicePointManager.DefaultConnectionLimit = 1000;

    Cheers
    Glen

    Tuesday, June 20, 2017 6:13 AM