Kasper Wittrup
Kasper Wittrup

Reputation: 491

The request channel timed out while waiting for a reply

I have a small application that uses WCF to communicate with a webserver. This program is used by some 200 clients, and each client is sending in about 5-20 requests/min.

Looking at the error logs I often get:

The request channel timed out while waiting for a reply after 00:00:59.9989999

The requests are made as follows:

ClientService Client = new ClientService();
Client.Open();
Client.updateOnline(userID);
Client.Close();

This is the app.config

<configuration>
<configSections>
</configSections>
<startup><supportedRuntime version="v2.0.50727"/></startup><system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IClientService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="PATH TO SERVICE"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IClientService"
            contract="IClientService" name="WSHttpBinding_IClientService">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

Of the "many calls" each day about 200-800 fail. And about n-1 are ok. I am very confused what the issue can be. Looking at the server stats, it's hardly building up a sweat - each request takes <2 sec to process. The data it's sending consists of "int" or "very small strings" - so, its not due to size, if it were - there should be a consistent failure..

Suggestions?

Upvotes: 34

Views: 98780

Answers (3)

Dmitry Harnitski
Dmitry Harnitski

Reputation: 6008

Check this performance counter - ASP.NET Requests Queued.

One web application can host many web pages and services. IIS processes only 12 concurrent requests per CPU core by default.

This means that even if your service is fast but other pages/services are slow your request has to wait in queue before they are executed.

ASP.NET Requests Queued should be zero or close to zero.

See Performance Counters for ASP.NET on MSDN.

Upvotes: 4

NTDLS
NTDLS

Reputation: 4872

Try adding the timeout values to both the service AND the client:

<binding name="BasicHttpBinding_SomeName" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00"
    sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

Upvotes: 45

Tabish Sarwar
Tabish Sarwar

Reputation: 1535

It seems that your requests are queuing up on server before being handled and then starts to time out. You can try couple of things here to see exactly whats going on

1) Try throttling in your WCF services e.g: Try increasing your concurrent sessions. Take a look WCF Throttling

2) Try using PerCall rather than Using Sessions here to make sure that no session remains there. Here is what you can do on your interface to remove session

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

and your contract classes implementing those interface

ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]

AND .... You should enable tracing to see exactly whats going on .

Upvotes: 13

Related Questions