Pregunta

I have hosted WCF service in a console application which is expected to run 24/7 and respond to requests from several applications. It works great if it gets requests continuously or even after 4 hrs of idle time. The code written to host the service is given below,

    static void Main(string[] args)
    {
        using (ServiceHost host = new ServiceHost(typeof(abcdService)))
        {
            host.Open();
            Console.ReadLine();
            host.Close();
        }
    }

In the WCF service, I was writing the output to console. When it throws the timeout error, I could see that the method in WCF service never received a request.

Is there any settings I need to do to make the self hosted WCF service respond to simple calls even after several hours of idle time?

The error I received is given below,

The request channel timed out while waiting for a reply after 00:00:59.9989999. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The HTTP request to '' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. ---> System.Net.WebException: The operation has timed out. Aborting test execution.

Note: When I restart the console application hosting WCF service, it starts to work fine again.

¿Fue útil?

Solución

Your requests might be queuing up on server before they are handled and then times out.

1) Try throttling in your WCF services.

2) Try using PerCall Use the following to remove the Session in your interface

[ServiceContract(Namespace="namespace", SessionMode=SessionMode.NotAllowed)]

Contract class implementing interface

ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]

You should be able to enable tracing to see exactly what is occurring.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top