0
votes

I have a weird issue in my Windows Azure project (c#)

My C# Azure app uses the Exchange Managed API to communicate with an Exchange 2010 server across the web.

Exchange 2010 itself is running in an Azure VM. I've opened up the firewall so that the Exchange EWS webservice is available on port 443.

When running locally in the Azure Emulator, my app works perfectly. I can see all the folders and emails in my account. It communicates with the Exchange VM across the web perfectly.

However, as soon as I publish my app to my staging environment, the app does not work properly.

The first call to the server works but after that, I receive this message:

"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [IPADDRESS]:443"

As I say, it works the first time (my Index page appears with the content I need) but if I refresh that page, it then gives me that error.

Therefore, I don't think it's a firewall issue, otherwise it wouldn't work the first time.

It's driving me to despair - I can't see what's wrong!

Hope you can help,

Simon.

[EDIT] Here's the stack trace:

[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond]
   System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) +136

[IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.]
   System.Net.Security._SslStream.EndRead(IAsyncResult asyncResult) +7911429
   System.Net.TlsStream.EndRead(IAsyncResult asyncResult) +2691856
   System.Net.Connection.ReadCallback(IAsyncResult asyncResult) +79

[WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.]
   System.Net.HttpWebRequest.GetResponse() +7864676
   Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(HttpWebRequest request) +130

[ServiceRequestException: The request failed. The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.]
   Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(HttpWebRequest request) +447
   Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(HttpWebRequest& request) +647
   Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() +72
   Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolder(FolderId folderId, PropertySet propertySet) +201
   Microsoft.Exchange.WebServices.Data.CalendarFolder.Bind(ExchangeService service, WellKnownFolderName name) +83
1
It's worth pointing out that Exchange works fine, Outlook Web Access is ok, my local emulator version still works and Outlook desktop.SimonGoldstone
OK, more weirdness. If I VIP swap production and staging, the app suddenly starts working in production mode without any issue. The production app now does not work in staging properly. But I'm pretty convinced the firewall is not the issue. I've also rebooted the Exchange server and it still doesn't work in staging. Any ideas?SimonGoldstone
Could it be that your application was experiencing a transient fault (temporary connection loss to the Exchange VM)? What happens if you swap back to staging, does it break again?Sandrino Di Mattia
Hi Sandrino, thanks for your message. If I swap it back, it breaks again! Nothing is indicating a connection fault as all my other ways of accessing Exchange continue as normal (RDP, OWA, Outlook, my Production version, etc.)SimonGoldstone
I'm logged in to my server with RDP and have a Perf Monitor session running. When my production app makes calls to the EWS I can see spikes in the graphs as expected. But when my staging version does the same, nothing. It's as if it is being firewalled but I'm convinced it isn't. The 443 endpoint is open in the Azure VM, the Windows Advanced Firewall has 443 open for all access (Domain, Private, Public) with no IP restrictions. IIS has 443 binding with no IP restictions. My staging app can access EWS once and then it breaks. It's as if there's some kind of flood control or something. Possible?SimonGoldstone

1 Answers

0
votes

I created a second cloud service and deployed my app to both production and staging environments. The app works in both perfectly!

So my theory is that for some reason, Exchange Web Service is blocking my staging app based on IP address. But there IS NO FIREWALL RULE!

Ok, so, this doesn't really answer "why" or "what's going on" but here's the solution I'm going with:

Delete the cloud app from Azure and re-deploy it completely!

This has the effect of generating a new IP address and suddenly my staging area works again.

Sorry I couldn't come up with anything better but a solution's a solution.