Question

I have the following code on WCF Service and I am using basicHttpBinding

public class Service1 : IService1
{
        public string GetData(int value)
        {
            // Sleep for a minute
            System.Threading.Thread.Sleep(60000);
            return string.Format("You entered: {0}", value);
        }
}



I have the following code on client and the client has a "sendTimeout" of only 1 second (I want the client to timeout before the server responds)

Service1Client clientProxy = new Service1Client();
        try
        {

            Console.WriteLine(clientProxy.GetData(10));
            clientProxy.Close();
        }            
        catch (TimeoutException)
        {
            if (((ICommunicationObject)clientProxy).State == CommunicationState.Opened)
            {
                // In the case of TimeoutException the state is not faulted and 
                // "close" is invoked
                clientProxy.Close();
            }
        }        



What I see in IIS log for the reqeust is:

2012-09-07 07:22:51 ::1 POST /SimpleTimeWCF/Service1.svc - 80 - ::1 - 200 0 64 60015

You can observe that the status is 200 and sc-win32-status is 64 and time-taken is 60015 (around a minute).

While the WCF service is busy processing the requesting, client has invoked clientProxy.Close. What is expected behavior on the server?

What is the expected behavior of "client proxy close" method invocation on the server when using basicHttpBinding?

Does the behavior change when using other bindings? Ex: Net TCP binding? When we use net tcp binding does invoking "close" on proxy on end the "tcp connection" established with the server?

PS: Note that I have set Enable HTTP Keep-alive on IIS to false

Was it helpful?

Solution

The service will get the request from the client. It will process the request, taking 60 seconds. The client has "given up" in the mean time, but with HTTP it has no way of notifying the service that the previous request is not needed anymore.

In the end, the service:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top