views:

210

answers:

4

I have an ASP.NET C# 3.5 web application that consumes another ASP.NET web service as a web reference. The web service is built into some proprietary hardware device. The problem is that that device has been having troubles and not alwasy accessible. My web application is suffering brcause of it, as it takes over a minute to load. It does load, but not acceptable.

The service is instantiated in a try catch block and no exception is being throw, but the output windows displays:

A first chance exception of type 'System.Net.WebException' occurred in System.dll

I know there is a better way to handle this, but I am drawing blanks.

Any help is appreciated.

UPDATE: Still looking for an answer on how to handle webservices that become unavailable without affecting website.

A: 

Without any details regarding frequency/usage of the service and not seeing any code, heres a thought or two.

Its most likely the web method on this hardware that giving the error, so I'd pursue any support options you have (if any), but just for giggles, try this first to see if it helps....

I noticed that some people online said that they were able to get around this (in their scenario) by setting the KeepAlive to false on the requesting object, so that way your aren't inadvertently using an old (stale) connection to the service. You may be trying to "Keep Alive" but the webserver timed out the connection on you. Worth a quick try...

Good Luck!

curtisk
There is bad code to show, I know the problem. The service is unavailable. I was looking more for how to handle the service in order to not affect my application. Basically I want to use the service when available, and gracefully degrade without it.Hope this clears things a bit. Thanks for you help
Dustin Laine
A: 

In addition to the above, I would use a http debugger (like fiddler2) to get a better idea of what is happening on the wire.

Wyatt Barnett
good point, fiddler is great
curtisk
Fiddler does not report any errors.
Dustin Laine
+1  A: 

If you saw a "first chance exception" but your exception handler didn't get it, that means that the exception was handled elsewhere (swallowed, consumed by an exception handler, etc.) Perhaps something in the .NET libraries already handled that exception, and you need not concern yourself with it in your code. Or maybe you left some exception swallowing somewhere in your code.

You ought to consider using a timeout in your web request.

Jacob
A: 

After tearing it apart, I found the exception. It is a standard "Unable to connect" exception. The problem is now the timeout, I have tried setting the asyncTimeout to 5000 in the web.config under the System.Web -> Pages properties. It is still taking aroung 20 seconds to throw the exception. Any ideas?

Dustin Laine
You should probably edit the question, not answer yourself. Are you hosting this in an async page? If not, that should not matter as the service call has separate configuration. If so, well, you did just set the timeout to 20 seconds. I would call the hardware vendor as it really sounds like the device is messing up.
Wyatt Barnett
You are right the hardware is messing up, but I want to ensure fault tolerance anyway being that the service is not 100% under my control. The page is async, but the service offers both sync and async methods.I am willing to use either method, The webservice is just display some not critical content, so I do not want it ot interfere with my application. Thanks for your help.
Dustin Laine