10

I'm using the EWS Managed API v2.2 to make EWS calls. Recently at one of my customers, we have a weird situation where service calls, any service call, never receives a response.

We are setting an explicit timeout, surrounding service calls with logging and are using EWS trace listening. The listener show the EWSRequest SOAP message, and that's it. The logging shows the "before service call" log entry but not the "after service call" entry.

I suspected throttling might be behind it and have temporarily removed the EWS throttling limits to no effect and in any case, I would expect an error response if throttling was kicking in.

This is how the service is initialised:

public ExchangeWebService(string username, string password, string emailAddress, string exchangeUrl, string exchangeVersion)
{
    ExchangeVersion exVersion = (ExchangeVersion)Enum.Parse(typeof(ExchangeVersion), exchangeVersion);
    _exchangeService = CreateExchangeService(username, password, emailAddress, exchangeUrl, exVersion);
    _exchangeService.Timeout = 30000;           
}

private static ExchangeService CreateExchangeService(string username, string password, string emailAddress, 
                                                             string exchangeUrl, ExchangeVersion exchangeVersion)
{

    IntegrationLogging _il = new IntegrationLogging(Constants.LoggingSourceName);

    ExchangeService service = new ExchangeService(exchangeVersion);
            QualifiedUserName qualifiedName = new QualifiedUserName(username);
    NetworkCredential credentials = new NetworkCredential(qualifiedName.UserName, password);

    if (qualifiedName.HasDomain)
    {
        credentials.Domain = qualifiedName.Domain;
    }

    service.Credentials = credentials;

    if (string.IsNullOrEmpty(exchangeUrl))
    {
        if (string.IsNullOrEmpty(emailAddress))
        {
            throw new ArgumentException("emailAddress and exchangeUrl parameters cannot both be empty");
        }
        else
        {
            _il.WriteTrace(string.Format("CreateExchangeService using auto discovery with email address {0} and user name {1}. {2}", emailAddress, username, Environment.StackTrace));
            service.AutodiscoverUrl(emailAddress);
        }
    }
    else
    {
        _il.WriteTrace(string.Format("CreateExchangeService using EWS URI {0} and user name {1}", exchangeUrl, username));
        service.Url = new Uri(exchangeUrl);
    }

    return service;
}

From one of the methods that never returns, we get the first log entry but not the second and our perf monitor shows the thread still running at the line of the service call.

_il.WriteTrace("ConvertInternalIdToEwsId:mailboxAddress=" + mailboxAddress);

AlternateIdBase _altBase = _exchangeService.ConvertId(_alternateId, IdFormat.EwsId);

_il.WriteTrace("ConvertInternalIdToEwsId:Returned from call");

return ((AlternateId)_altBase).UniqueId;

The service instance is of type Microsoft.Exchange.WebServices.Data.ExchangeService.

This problem seems to be intermittent. How can a call not result in a response, an exception or a timeout?

Simon
  • 14,407
  • 8
  • 46
  • 61
  • 2
    Have you checked a network trace, eg fiddler or wireshark to see if the call is being sent to the server? Or if any response is being received? – tjleigh Apr 18 '15 at 23:06
  • Is your application multi-threaded? – Yacoub Massad Oct 19 '15 at 11:58
  • @YacoubMassad Hi Yacoub. Yes it is. Although, I believe only one thread is trying to access the service at a time. What are you thinking? – Simon Oct 21 '15 at 13:18
  • @Simon, I faced the same issue before. And my application was multi threaded. Do you use the same `ExchangeService` instance from multiple threads? To fix my problem, I connected to EWS directly without the Managed API. Take a look at [this](https://msdn.microsoft.com/en-us/library/office/exchangewebservices%28v=exchg.150%29.aspx). – Yacoub Massad Oct 21 '15 at 13:30

1 Answers1

0

Hey I'll double check when I'm at the office... but had a similar issue...

In my case it does eventually return, had to leave it for quite sometime.

I had mine wrapped in a try/catch, and put a break point on the catch.

Cannot remember, but i think this happened when I was using the wrong auto discover email Address.

try
{
    service.AutodiscoverUrl(emailAddress);
}
catch (Exception) 
{  //break point here and leave for at least 10 min
    throw;
}
Seabizkit
  • 2,417
  • 2
  • 15
  • 32