大约10次左右的呼叫后,WCF停止响应(限制)

And*_*ech 39 c# wcf web-services throttling

我有一个WCF服务和一个带有服务引用的应用程序,并且在应用程序中我有一个循环,并且在每次迭代中它都在调用这个wcf web服务中的方法.

问题是,在大约9次呼叫之后,它就会停止......如果你Pause按下VS的按钮,你会看到它停留在拨打电话的线路上.

等待一段时间后,抛出此TimeoutException:

在00:00:59.9970000之后等待回复时,请求通道超时.增加传递给Request的调用的超时值或增加Binding上的SendTimeout值.分配给此操作的时间可能是较长超时的一部分.


我对此进行了一些研究,发现了一些涉及在应用程序中编辑app.config的解决方案,以下是它的摘录:

<serviceBehaviors>
    <behavior name="ThrottlingIssue">
        <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" />
    </behavior>
</serviceBehaviors>
Run Code Online (Sandbox Code Playgroud)

.

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
 maxArrayLength="2147483647" 
 maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
Run Code Online (Sandbox Code Playgroud)

然后,在我停止调试后,几分钟后,会弹出一条错误消息,告诉我发生了灾难性故障.

我该如何解决这个问题?当我使用普通的Web服务时,我没有遇到此问题.


供参考,以下是整体app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ThrottlingIssue">
                    <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IDBInteractionGateway" 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="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" establishSecurityContext="true" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:28918/DBInteractionGateway.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDBInteractionGateway"
                contract="DBInteraction.IDBInteractionGateway" name="WSHttpBinding_IDBInteractionGateway">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

[更新]解决方案:

显然,在每次请求之后你都需要Close连接 ...我现在正在关闭每个请求之后的连接,它就像一个魅力.

虽然我仍然无法理解的是,在我的app.config中,我将maxConcurrentCalls和maxConcurrentSessions设置为500,然而,我只能制作10.任何人都有任何答案吗?(也许我在上面发布的app.config中有错误)

上述问题(现在为虚线)的答案是因为我正在编辑客户端app.config,而不是服务配置文件(web.config)

mar*_*rkt 27

允许的并发连接的默认数量为10.
很可能您的客户端没有关闭连接.

要增加并发调用的数量,您必须将您的行为添加到服务配置,而不是客户端.

  • 允许并发连接是不够的.他仍然需要关闭联系. (2认同)