请求通道在等待回复时超时

Kas*_*rup 29 c# wcf

我有一个小应用程序,它使用WCF与Web服务器通信.该程序由大约200个客户端使用,每个客户端以大约5-20个请求/分钟发送.

查看错误日志我经常得到:

在00:00:59.9989999之后等待回复时,请求通道超时

请求如下:

ClientService Client = new ClientService();
Client.Open();
Client.updateOnline(userID);
Client.Close();
Run Code Online (Sandbox Code Playgroud)

这是app.config

<configuration>
<configSections>
</configSections>
<startup><supportedRuntime version="v2.0.50727"/></startup><system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IClientService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="PATH TO SERVICE"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IClientService"
            contract="IClientService" name="WSHttpBinding_IClientService">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

在"多次通话"中,每天约200-800次失败.约n-1是好的.我很困惑这个问题是什么.查看服务器统计信息,它几乎没有出汗 - 每个请求都需要<2秒才能处理.它发送的数据包括"int"或"非常小的字符串" - 因此,它不是由于大小,如果是 - 应该有一致的失败..

建议?

NTD*_*DLS 36

尝试将超时值添加到服务和客户端:

<binding name="BasicHttpBinding_SomeName" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00"
    sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
Run Code Online (Sandbox Code Playgroud)


Tab*_*war 11

您的请求似乎在处理之前在服务器上排队,然后开始超时.你可以在这里尝试几件事来看看到底发生了什么

1)尝试在WCF服务中进行限制,例如:尝试增加并发会话.看一看 WCF Throttling

2)尝试使用PerCall而不是使用Sessions来确保没有会话.您可以在界面上执行以下操作来删除会话

[ServiceContract(Namespace="YOUR NAMESPACE", SessionMode=SessionMode.NotAllowed)]
Run Code Online (Sandbox Code Playgroud)

和您的合同类实现这些接口

ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
Run Code Online (Sandbox Code Playgroud)

AND ....您应该启用跟踪以查看到底发生了什么.