Monday, April 4, 2011

TimeoutException The request channel timed out while waiting for a reply after 00:01:00. WCF web service

The default value for the send timeout is "00:01:00". If the operation requested by the service consuming application takes more than a minute, the service may have completed the operation, but by the time the application gets the response, the application throws the following exception:

TimeoutException The request channel timed out while waiting for a reply after 0
0:01:00. Increase the timeout value passed to the call to Request or increase th
e SendTimeout value on the Binding. The time allotted to this operation may have
 been a portion of a longer timeout.

If we closely observe the exception, it says to increase the SendTimeOut value. So from the client side we have to increase the SendTimeOut value let say to "00:50:00" or some bigger value.

But, how much to increase? That we can find out by cumulative time taken to request the service + operation time of the service + service response time. We may have to check for the most largest operation expected by the application to perform.

Other option is to follow the following link in the code project:

This might resolve the timeout issue.

There was no endpoint listening at https://.... that could accept the message

Most of the times we get this error while consuming the hosted web service. For any exception, the what we must understand is what the exception is speaking about exactly and what is the inner exception.

The inner exception gives more details about the cause of the exception. We may have to pay attention to the details of the inner exception. For example, if the inner exception says "The remote server returned an error: (404) Not Found". If we browse the service directly, you may see the wsdl link and everything may work fine. This irritates most of the programmers.

What is the solution for this problem?
1. Get the log in the IIS server for the service. Also check the service hostname that you are accessing to and the specified one in the WSDL are same.
2. Find out the sub error code for 404 in the log. The error may not be because of the endpoint, but the infrastructure supporting endpoint. May be the resource accessed by the service is locked or not available.
3. If the services are load balanced on two or more servers, check to see if individual servers are responding by making one server passive and other one active.
4. If everything is right, then the issue might be with the load balancer.