I am currently troubleshooting an issue related to Exchange Web Services. The issue is that, upon opening a connection to a Streaming Subscription (via the StreamingSubscriptionConnection object), the operation hangs when calling the Open method. Here is the code that hangs, for reference:
_streamingSubscriptionConnection = new StreamingSubscriptionConnection(_exchangeService, _connectionLifetime);
_streamingSubscriptionConnection.AddSubscription(_subscription);
_streamingSubscriptionConnection.OnNotificationEvent += new StreamingSubscriptionConnection.NotificationEventDelegate(OnNotificationEvent);
_streamingSubscriptionConnection.OnSubscriptionError += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnSubscriptionError);
_streamingSubscriptionConnection.OnDisconnect += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnDisconnect);
_streamingSubscriptionConnection.Open();
It usually takes about two minutes and then it throws a ServiceRequestException whose message is:
The request has failed. The operation has timed out.
It’s also worth mentioning that even if I set the timeout to a minute, it will still take longer than a minute and then throw this exception. The call never gets past that Open command.
My questions are, has anyone come across this in the past? Additionally, are there any tools available that I can use to diagnose any connection issues to determine if the exception is on my end, the Exchange servers end, or somewhere in the middle? I’ve tried Fiddler and Microsoft Network Monitor to look for any patterns but I’m having a hard time discerning anything.
Thanks in advance!
EDIT: To add on to this, if I add a trace listener I get quite a lot of output. I can see it retrieve the Subscription Id and then attempt to connect. When it sends out the request to connect, this is what is logged between the time the Open command is issued and the timeout:
<Trace Tag="EwsRequestHttpHeaders" Tid="10" Time="2013-01-24 19:16:18Z">
POST /ews/exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/14.03.0032.000
Accept-Encoding: gzip,deflate
</Trace>
<Trace Tag="EwsRequest" Tid="10" Time="2013-01-24 19:16:18Z" Version="14.03.0032.000">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP1" />
</soap:Header>
<soap:Body>
<m:GetStreamingEvents>
<m:SubscriptionIds>
<t:SubscriptionId>GABsdGNmaXN3bXNnY2EwNi5mbmZpcy5jb20QAAAAnQCowdNSt0iTEhqVr8+a1GPHu2t+yM8I</t:SubscriptionId>
</m:SubscriptionIds>
<m:ConnectionTimeout>30</m:ConnectionTimeout>
</m:GetStreamingEvents>
</soap:Body>
</soap:Envelope>
</Trace>
I’m attempting to rule out network issues, but having a bit of a hard time doing so. Any advice is welcome at this point.
For those who come after me, this issue wound up not being anything related to .Net or the EWS library.
The issue wound up being related to persistence settings on the load balancers in our company. With our load balancers, if any kind of persistence is enabled for EWS streaming subscription calls, those connections will fail. Unfortunately, at the time I wasn’t aware there was a load balancer between myself and the Exchange server since developers don’t have access to that infrastructure here.
Regardless, hopefully this helps someone out in the future!