Wednesday, June 27, 2012

Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property)

In my client application program I am referring to the service

myServiceReference.HelloWorldClient proxy = new Client.myServiceReference.HelloWorldClient("NetTcpBinding_IHelloWorld");
Console.WriteLine(proxy.ShowData("Hi There!"));

Here ShowData(string message) is a method that accepts a parameter of type string and returns a string. For testing purpose, I have added code for Thread.Sleep for 2 minutes. The default operation timeout on a WCF client channel is 00:01:00 (1 minute). So, the method call will result into the following exception:

This request operation sent to net.tcp://localhost:9000/ did not receive a reply within the configured timeout (00:01:00).  The time allotted to this operation may have been a portion of a longer timeout.  This may be because the service is still processing the operation or because the service was unable to send a reply message.  Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client.
<netTcpBinding>
                <binding name="NetTcpBinding_IHelloWorld" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>

Increase the send timeout value:
sendTimeout="00:20:00"
The time required to increase the timeout value depends on the maximum response time of the service for a request.
If this does not fix the issue, the other way around as suggested by the error message itself is as below:
 myServiceReference.HelloWorldClient proxy = new Client.myServiceReference.HelloWorldClient("NetTcpBinding_IHelloWorld");
           
proxy.InnerChannel.OperationTimeout = new TimeSpan(0, 20, 00);
Anyways we need to know the service response time for a method call to set the operation timeout and fix the issue.

3 comments:

Marc said...

Thanks man. That was exactly what I was looking for.

aldex said...

nice..

Zahid said...

Thanks for the information!!

Post a Comment