Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How: Web Service and handling Client Timeouts in the Web Service?

I am trying to log what is happening when the Client gets a time out on a Web Service call.

Take a look at the HelloWorld code below. This is what I wish to do, but it seems IsClientConnected does not work as it allways return true.

[WebMethod]
public string HelloWorld() {
    //.. Do the Webservice stuff
    if (!Context.Response.IsClientConnected) {
        //Log some vital info about this call that timed out...
    }
    return "The WebService Result";
}

Does anyone know another way to check the state of the Web Service call?

When clients disconnect from a webservice call, there are no Exceptions thrown in the Web Service. The code continues to run untill it is done and then returns its result into nothingness (as the connection is closed).

like image 557
Wolf5 Avatar asked Aug 12 '09 11:08

Wolf5


People also ask

How do you handle timeout in web services?

You can control the connection and socket timeout of the loading of the WSDL definition by setting enable-wsdl-discovery-timeouts . Use the value -1 to use the default of the underlying infrastructure. Use the value 0 to disable the timeouts. Use a positive integer to specify a timeout in milliseconds.

What is client timeout?

Client timeouts, also called idle timeouts, occur when a client is disconnected from a Relay server after being inactive for longer than the 10 second TTL value. A TTL value, or time to live value, is a mechanism that limits the lifetime of idle connections to a Relay server.

How does connection timeout work?

A server connection timeout means that a server is taking too long to reply to a data request made from another device. Timeouts are not a reply message: they show up when there isn't a reply and a server request is not fulfilled in a predetermined length of time.


1 Answers

I don't believe there will be an exception in general. Even if the service were sending back a long response, such that the outgoing transmission window closed, and timed out waiting to be able to send bytes, all of this would be occurring after the web method had returned back to ASP.NET.

What you should do is learn which web methods are taking too long. You can begin to do this by turning on tracing, as shown in "Enabling Tracing in ASP.NET Web Services". You may then need to go further, and profile the service to see where time is being spent.

You should also look carefully at the event logs. In particular, look for warning events from the "ASP.NET" event source. These come from ASP.NET Health Monitoring. I recommend you get to know the Health Monitoring system, as you may find it does many things for you that you'd have to write yourself, simply at the cost of configuration.

like image 129
John Saunders Avatar answered Sep 28 '22 09:09

John Saunders