Friday, March 2, 2012

WCF Service Errors

ERROR 1:TimeoutException

The request channel timed out while waiting for a reply after 00:00:59.9970000. 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.
SOLUTION:
1)A call to clientservice.close() will solve the problem.

REFERENCES:
1)
 http://stackoverflow.com/questions/739312/c-sharp-wcf-wcf-stops-responding-after-about-10-or-so-calls-throttling
==================================================================
2)
 why do I have to Close a service Proxy? http://geekswithblogs.net/marcel/archive/2007/05/01/112159.aspx
===============================================================

3)
http://www.codeguru.com/csharp/.net/net_wcf/article.php/c15941/        
StockService.StockServiceClient client = new StockService.StockServiceClient(
              "StockBasicHttpEndpoint", stockServiceUrl);

string StockId = client.GetStockIdByName("MSFT");

//Done with the service, let's close it.
try
{
   if (client.State != System.ServiceModel.CommunicationState.Faulted)
   {
      client.Close();
   }
}
catch (Exception ex)
{
   client.Abort();
}
==================================================
4)http://msdn.microsoft.com/en-us/library/ms735103.aspx
     
CalculatorClient wcfClient = new CalculatorClient();
try
{
    Console.WriteLine(wcfClient.Add(4, 6));
    wcfClient.Close();
}
catch (TimeoutException timeout)
{
    // Handle the timeout exception.
    wcfClient.Abort();
}
catch (CommunicationException commException)
{
    // Handle the communication exception.
    wcfClient.Abort();
}



No comments: