WCF超时错误 - 即使在增加值之后

时间:2011-09-01 17:10:09

标签: wcf timeout

我的客户一直在抱怨他们收到超时错误,但我没有看到我身边生成的跟踪文件。有谁能告诉我如何解决这个问题?

我已经将receiveTimeout增加到15分钟(00:15:00)。我在WCF服务端和客户端都这样做了。我的服务不是一个长时间运行的过程,客户端应该在最多0到2分钟内收到响应

不仅是receiveTimeout而且我将所有超时设置为00:15:00,同时我将serviceThrottling(maxConcurrentCalls,maxConcurrentInstances,maxConcurrentSessions)设置为200.

注意:如果有超时错误,我在跟踪中看不到与此相关的任何内容。

这是我的配置文件,

WCF服务配置:

<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>

客户端配置:

<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>

这是客户端代码

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; 
    } 
} 

由于

1 个答案:

答案 0 :(得分:0)

超时错误很难诊断。我们遇到的问题与WAN延迟完全相关,同时通过网络传递大型数据集。

但是,如果您发现超时发生后,无法再调用Web服务,我会查看此WCF 3.5 & 4.0 Hotfix