Freigeben über


Timeouts and WCF - httpRuntime

There seems to be very little documentation around the timeout behaviors for the client and service and configuring so many knobs can get you in a fix if you dont know what you are tweaking. The below snippet shows how enable one of these scenarios to keep connections open for long processing message. Bad as it sounds this might be required if we are designing a synchonour system with large processing times per service.

The underlying fact is that in v1 of WCF there is more than the knobs.
The underlying httpRuntime is also responsible for the connection and this knob also needs to be set to accept long calls and large execution times.

<

system.web>
<httpRuntime executionTimeout="400000"/>
</system.web>

The next setting required to be done is on the client. We also need t specify the sendTimeout if we know that the send process is going to take a while.

            ChannelFactory<ServiceReference.IService1> cf = new ChannelFactory<Client.ServiceReference.IService1>("BasicHttpBinding_IService1");

            BasicHttpBinding b = (cf.Endpoint.Binding as BasicHttpBinding);

            b.SendTimeout = new TimeSpan(0,6,10);

           

            IService1 proxy = cf.CreateChannel();

            try

            {

                Console.WriteLine(proxy.GetData(6));

                Console.ReadLine();

            }

            finally

            {

                if((proxy as IChannel).State == CommunicationState.Opened)

                    (proxy as IChannel).Close();

            }

Comments