1

My client keep complaining that they are receiving Timeout error but I don't see a trace file generated on my side. Can anybody tell me how to fix this?

I already increase the receiveTimeout to 15 minutes (00:15:00). I did this both on WCF service side and on the client side. My service is not a long running process, the client should receive the response in 0 - 2 minutes max.

Not only receiveTimeout and I set the all timeouts to 00:15:00, also I set the serviceThrottling (maxConcurrentCalls,maxConcurrentInstances,maxConcurrentSessions) to 200.

Note: When ever there is an Timeout error, I don't see anything related to that in Tracing.

Here is my config files,

WCF Service Config:

<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="150" maxRequestLength="8192" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="MYWS" name="MYDEMO.MYDEMOCLS">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="SecureBinding" name="wsDemo" contract="MYINTERFACES.ICustomer">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="wsMex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.1/Customer/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MYWS">
<serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="200" maxConcurrentSessions="200" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="SecureBinding" maxBufferPoolSize="2147483647" closeTimeout="00:15:00" openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Message">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>

Client Config:

<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="150" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsDemo" closeTimeout="00:15:00" openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:15:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.0.1/DEMOSVCS/Customer.svc" binding="wsHttpBinding" bindingConfiguration="wsDemo" contract="PROJ.IFACE" name="wsDemo">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>

Here is a client code

DemoClient client = new DemoClient("wsDemo"); 
DemoResponse DemoResponse = new DemoResponse(); 
try 
{ 
    DemoResponse = client.CreateProduct(product); 
    client.Close(); 
    return DemoResponse; 
} 
catch (Exception ex) 
{ 
    try 
    { 
        if (client.State == CommunicationState.Faulted) 
            client.Abort(); 
        else 
            client.Close(); 
        throw ex; 
    } 
    catch 
    { 
        client.Abort(); 
        throw ex; 
    } 
} 

Thanks

oleksii
  • 35,458
  • 16
  • 93
  • 163
CoolArchTek
  • 3,729
  • 12
  • 47
  • 76
  • Is this the code from the actual client config file or is it your version of it? I'm asking because you have debug="true" set and executionTimeout set. When debug="true" then the executionTimeout doesn't have any effect but as soon as you set it to false, then it will. – evasilchenko Sep 01 '11 at 19:41
  • Show us the client calling code. How do you close the proxy? – oleksii Sep 01 '11 at 19:44
  • `code` DemoClient client = new DemoClient("wsDemo"); DemoResponse DemoResponse = new DemoResponse(); try { DemoResponse = client.CreateProduct(product); client.Close(); return DemoResponse; } catch (Exception ex) { try { if (client.State == CommunicationState.Faulted) client.Abort(); else client.Close(); throw ex; } catch { client.Abort(); throw ex; } } `code` Here is my code, its missing format. – CoolArchTek Sep 01 '11 at 20:15
  • DeviantSeev I think I have debug set to 'true'. I will check it anyways. What else you see wrong in it? @oleksii see my previous comment. I added the code there. – CoolArchTek Sep 01 '11 at 20:22
  • @CoolArchTek what kind of service instance management do you use? Singleton? Maybe the is a pile of requests queued while a singleton struggle to process the requests and some of them expire? As to config in your app it is actually only one config that matter for timeouts, the one on the client, as the service doesn't use any callback contract. – oleksii Sep 01 '11 at 22:30
  • @oleksii How do I find out if service is a SingleTon? I didn't specify any attributs for ServiceContract or OperationContact. Can you please explain how to find out? – CoolArchTek Sep 02 '11 at 14:28

1 Answers1

0

Timeout errors are hard to diagnose. We've had issues that were completely related to WAN latency while passing large datasets across the wire.

However, if you find that once the timeout occurs, no further calls to the web service can be made, I would look into this WCF 3.5 & 4.0 Hotfix

Bahri Gungor
  • 2,289
  • 15
  • 16
  • I know they are very hard to diagnose. That's why I am here asking for help. right now I am out of ideas. @oleksii DO you have anything for me? – CoolArchTek Sep 01 '11 at 22:34
  • @CoolArchTek I mean not really, my guess was a proxy closing - but that's fine. Perhaps check the service instance management, maybe calls are somehow buffered (if it is a singleton) – oleksii Sep 01 '11 at 23:15
  • @oleksii _italic_Perhaps check the service instance management, maybe calls are somehow buffered (if it is a singleton)_italic_ Can you please explain me how? – CoolArchTek Sep 02 '11 at 14:23
  • @CoolArchTek Check if the service class use *Single* instance, take a look [here](http://msdn.microsoft.com/en-us/magazine/cc163590.aspx#S6). If it is a singleton `InstanceContextMode = InstanceContextMode.Single`, all calls from many clients are processed by only one service instance in one thread in a queue manner. Maybe the queue gets long enough and some clients have been waiting for 15 mins in a queue without being served, coz service is just too busy with previous calls. It's just a guess. – oleksii Sep 02 '11 at 17:00
  • @oleksii Since I did not specify anything in the service class, I guess it will be determined based of my config values(see my client config). see this link [link] http://www.suntsu.ch/serendipity/index.php?/archives/191-What-is-the-default-for-WCF-if-InstanceContextMode-is-not-set-explicit.html [/link] since I disable reliablesession and using security mode="message" I guess it is 'PerSession' Is that wrong? or do want me to change it to something else? – CoolArchTek Sep 02 '11 at 17:57
  • @CoolArchTek, I don't have any other clue, maybe see this post and investigations http://stackoverflow.com/questions/981475/wcf-timeout-exception-detailed-investigation – oleksii Sep 03 '11 at 20:06
  • I think your best bet might be to go to your client and look at their environment. Make sure it is up to par on latest versions and patches, then check the latency between the client computer and the server. Without more symptoms, it is hard to provide more guidance on what to do next. – Bahri Gungor Sep 06 '11 at 00:06
  • @oleksii I wanted to mention couple more things, 1. I have developed this service using .net 4.0 and client is NOT .net 2. This WCF service not directly exposed to client (out side firewall), we created a Webservice (asmx) wrapper around it. And that asmx service is visible outside. WCF --> Webserice (asmx) --> Client Client for WCF serivce is Webservice (which is internal) – CoolArchTek Sep 06 '11 at 13:26
  • @CoolArchTek oh man... this is a bit hacky :) I am not sure how can you resolve it. I would start (if possible) by reducing the complexity and sticking to one technology if possible. Can you use ASMX webservices instead of WCF? – oleksii Sep 06 '11 at 16:16
  • @CoolArchTek I suggest not using ASMX, which is the older technology, and simply add a Basic HTTP listener to your WCF service (which any ASMX capable client should be able to subscribe to). Why the passthrough Cool? Opening the service up and bypassing the ASMX service would be easier to troubleshoot. – Bahri Gungor Sep 06 '11 at 16:23
  • @oleksii and Bahri Gungor Today when I call the webservice and I got this error, `code` System.Net.WebException: The operation has timed out at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) `code` – CoolArchTek Sep 06 '11 at 17:08
  • @CoolArchTek This new exception is for the inner WCF service or the outer ASMX service? – Bahri Gungor Sep 06 '11 at 17:28
  • Its from ASMX Service. In the WCF trace I see the entries, i.e call is reaching out to WCF service. Also I see 'Close ServiceHost' entries in WCF trace file. I don't know why the webservice (ASMX) is taking more time. In this case ASMX webservice just calls WCF service and returns the value that it received from WCF service. NO logic inside the ASMX service. – CoolArchTek Sep 06 '11 at 17:53