【发布时间】:2017-03-16 11:02:37
【问题描述】:
我在使用 WCF 服务时遇到问题。我在控制台应用程序中使用了我的 WCF 服务,它可以正常工作,直到 100 个请求(循环)。但它在 100 个请求后停止工作。我已经用过
<serviceThrottling
maxConcurrentCalls="500"
maxConcurrentInstances="500"
maxConcurrentSessions="500"/>
在我的配置中,但对这个问题没有影响。每次调用服务后我都关闭了连接,但问题仍然存在。
非常感谢任何帮助。
下面是我的 web.config :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add name="PriceGain" connectionString="Server=xyz.abc.com;Database=SomeDB;User Id=appuser;password=xxxxxxx;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<services>
<service name="AirGainUtilities.Service.Utilities" behaviorConfiguration="UtilitiesBehavior">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint address="http://192.168.1.1/AirGain.Utilities.Service/Utilities.svc" binding="basicHttpBinding" contract="AirGainUtilities.Service.IUtilities" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="UtilitiesBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling
maxConcurrentCalls="5000"
maxConcurrentInstances="5000"
maxConcurrentSessions="5000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<add value="Utilities.svc" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
【问题讨论】:
-
启用 FaultExceptions 时遇到什么错误?
-
嗨 Shuto,事实上,我也没有遇到任何异常,我是 WCF 的新手,可能是我做错了什么:public List
GetDestinationHotelId(string DestinationAirport) { try { 包 objPkg = new Package();返回 objPkg.GetDestinationHotelId(DestinationAirport); } catch (Exception fe) { throw new FaultException(fe.Message); } //返回空值;以上是我的服务契约方法。 -
下面是我使用它的客户端应用程序代码:int x = 0; while (true) { x++;使用 (AirGainUtilities.Service.UtilitiesClient UC = new AirGainUtilities.Service.UtilitiesClient()) { List
lstHotels = UC.GetDestinationHotelId("SJD");如果 (lstHotels.Count -
请编辑您的问题并在此处添加客户代码
-
糟糕,我发现了问题...它与 WCF 无关。类包代码中有一个问题,没有引发任何错误。抱歉,谢谢 daniell89,Shuto Mbofana,
标签: c# .net wcf service connection