Dustin Laine
Dustin Laine

Reputation: 38503

Webservice unavailable

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.


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?

Upvotes: 0

Views: 785

Answers (4)

Dustin Laine
Dustin Laine

Reputation: 38503

Simple solution, poll the service using JavaScript after page load.

Upvotes: 1

Jacob
Jacob

Reputation: 78850

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.

Upvotes: 1

Wyatt Barnett
Wyatt Barnett

Reputation: 15673

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.

Upvotes: 0

curtisk
curtisk

Reputation: 20175

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!

Upvotes: 0

Related Questions