Invalid Operation Exceptions

I’m using a small C# console appliction to get data. During an extract that typically runs an hour or so I’m periodically getting the error shown below. The errors typically occur at the following line…I can enclose in a try/catch but would like to understand why these two errors occur? Thanks.

When executing this line…

AirlineFlightInfoStruct aifi = df.AirlineFlightInfo(z.faFlightID);

1. First Error (most common)
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Client found response content type of ‘text/html;charset=utf-8’, but expected ‘text/xml’.
The request failed with the error message:

Service Interruption
We're sorry, but FlightAware has encountered an unrecoverable error and is unable to process your request at this time. Please try again shortly or wait a few moments. If the problem persists, please contact us.
Error ID:
Service Interruption
			<script type="text/javascript">
	$(function() {
		$("body").append("<iframe src='/ajax/ignoreuser/hash2.rvt?k=travel,flight' style='display: none;'></iframe>");
	});
</script>

–.
Source=System.Web.Services
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object] parameters)
at FlightXML2.AirlineFlightInfo(String faFlightID)
at Flightaware1.Program.Main(String] args) in H:\faware\Flightaware1\Flightaware1\Flightaware1\Program.cs:line 4566
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

**2. Second Error **

invalid operation: System.InvalidOperationException: Client found response content type of ‘text/html;charset=utf-8’, but expected ‘text/xml’.
The request failed with the error message:

FlightAware is temporarily unavailable
<style>
	body {
		margin: 0;
	}
	#sitedown-container {
		width: 728px;
		margin: 50px auto 20px;
		font-family: sans-serif, 'Sans Serif', Arial, Helvetica;
	}
	#sitedown-logo {
		padding: 10px 25px 10px 0;
		float: left;
	}
	#sitedown-message {
		float: left;
		padding: 10px 0 10px 25px;
		width: 515px;
		margin-bottom: 40px;
		border-left: 1px solid rgb(221, 221, 221);
	}
	#sitedown-message h1 {
		font-size: 20px;
		margin: 0 0 0.5em 0;
	}
	#sitedown-message p {
		font-size: 16px;
		margin: 0;
	}
	#sitedown-container > iframe {
		margin: 20px auto !important;
	}
	#sitedown-twitter {
		text-align: center;
	}
	#sitedown-twitter iframe {
		width: 100%;
	}
	footer {
		text-align: center;
		color: #999;
		font-size: 10px;
	}
</style>
<div style="text-align: right; font-size: 8px">wlmor</div>
<div id="sitedown-container">
	<div id="sitedown-logo">
		<img src="http://flightaware.com/images/logo.png" alt="FlightAware Logo" />
	</div>

	<div id="sitedown-message">
		<h1>FlightAware is temporarily unavailable</h1>
		<p>We're working on restoring service as soon as possible. <em>Expect departure clearance shortly.</em></p>
	</div>

	<div style="clear: both"></div>

	
	<iframe name="FA_ads_434754" width="728" height="90" align="middle" frameborder="0" style="display: block; margin: 0 auto;" scrolling="no" marginwidth="0" marginheight="0"></iframe>
	<script>var lazyload_ads = lazyload_ads || ]; lazyload_ads.push("FA_ads_434754", "//ad.doubleclick.net/N6254/adi/flight.main/error;sz=728x90;dcove=d;dc_ref=http%3A%2F%2Fflightxml.flightaware.com%2Fsoap%2FFlightXML2%2Fop;tile=1"]);</script>
	<noscript>
	 <iframe
	  url="//ad.doubleclick.net/N6254/adi/flight.main/error;sz=728x90;dcove=d;dc_ref=http%3A%2F%2Fflightxml.flightaware.com%2Fsoap%2FFlightXML2%2Fop;tile=1;nojs=1;ord=664443592885"
	  width="728" height="90" frameborder="0" style="display: block; margin: 0 auto;" scrolling="no"></iframe>
	</noscript>
	

	<div id="sitedown-twitter">
		<a class="twitter-timeline" href="https://twitter.com/flightaware/outage-updates" data-widget-id="332174758860963840">Follow @FlightAwareOps on Twitter</a>
		<script defer="defer">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
	</div>

	
	<iframe name="FA_ads_926142" width="728" height="90" align="middle" frameborder="0" style="display: block; margin: 0 auto;" scrolling="no" marginwidth="0" marginheight="0"></iframe>
	<script>var lazyload_ads = lazyload_ads || ]; lazyload_ads.push("FA_ads_926142", "//ad.doubleclick.net/N6254/adi/flight.main/error;sz=728x90;dcove=d;dc_ref=http%3A%2F%2Fflightxml.flightaware.com%2Fsoap%2FFlightXML2%2Fop;tile=2"]);</script>
	<noscript>
	 <iframe
	  url="//ad.doubleclick.net/N6254/adi/flight.main/error;sz=728x90;dcove=d;dc_ref=http%3A%2F%2Fflightxml.flightaware.com%2Fsoap%2FFlightXML2%2Fop;tile=2;nojs=1;ord=664443592885"
	  width="728" height="90" frameborder="0" style="display: block; margin: 0 auto;" scrolling="no"></iframe>
	</noscript>
	

	<footer>
		© FlightAware
	</footer>
</div>
<!-- Connection to database failed

timeout expired



–.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object] parameters)
at FlightXML2.MetarEx(String airport, Int32 startTime, Int32 howMany, Int32 offset)
at Flightaware1.Program.Main(String] args)

I believe those were transient errors caused by some service outages at the time. Are you still having this problem?

Yes, we’re still receiving these errors. We run pulls each day on a list of aircraft and get a large number of these errors. I’ve listed a snippet from the log file for todays run. We’re trying to determine the state of our data in regards to timeliness and how complete the returned data is. These errors make it difficult to make that determination. Thanks for taking a look.

Start Log 7/21/2015 7:22:22 AM
N961AM RJAA Tokyo (Narita) 1437198650
invalid operation: System.InvalidOperationException: Client found response content type of ‘text/html;charset=utf-8’, but expected ‘text/xml’.
The request failed with the error message:

Service Interruption
We're sorry, but FlightAware has encountered an unrecoverable error and is unable to process your request at this time. Please try again shortly or wait a few moments. If the problem persists, please contact us.
Error ID:
Service Interruption
			<script type="text/javascript">
	$(function() {
		$("body").append("<iframe src='/ajax/ignoreuser/hash2.rvt?k=travel,flight' style='display: none;'></iframe>");
	});
</script>

–.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object] parameters)
at FlightXML2.MetarEx(String airport, Int32 startTime, Int32 howMany, Int32 offset)
at Flightaware1.Program.Main(String] args)
Soap Exception: System.Web.Services.Protocols.SoapException: no results
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object] parameters)
at FlightXML2.MetarEx(String airport, Int32 startTime, Int32 howMany, Int32 offset)
at Flightaware1.Program.Main(String] args)
C-GHPT CYVR Vancouver, British Columbia 1437325568
invalid operation: System.InvalidOperationException: Client found response content type of ‘text/html;charset=utf-8’, but expected ‘text/xml’.
The request failed with the error message:

Service Interruption
We're sorry, but FlightAware has encountered an unrecoverable error and is unable to process your request at this time. Please try again shortly or wait a few moments. If the problem persists, please contact us.
Error ID:
Service Interruption
			<script type="text/javascript">
	$(function() {
		$("body").append("<iframe src='/ajax/ignoreuser/hash2.rvt?k=travel,flight' style='display: none;'></iframe>");
	});
</script>

–.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object] parameters)
at FlightXML2.MetarEx(String airport, Int32 startTime, Int32 howMany, Int32 offset)
at Flightaware1.Program.Main(String] args)
Soap Exception: System.Web.Services.Protocols.SoapException: no data available
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object] parameters)
at FlightXML2.FlightInfoEx(String ident, Int32 howMany, Int32 offset)
at Flightaware1.Program.Main(String] args)

In general, the “Connection to database failed” occurs when our website is under high utilization. We are in the process of increasing our capacity, which should minimize these problems. You can make your application retry such operations when an unsuccessful response is received, with the expectation that it will succeed then.