C# WCF web服务太忙

C# WCF web服务太忙,c#,wcf,service,web,C#,Wcf,Service,Web,我对繁忙的wcf服务有一个问题,客户可以通过该服务连接并使用它。 下面是该类的服务器配置和属性的错误和堆栈跟踪 错误消息和堆栈跟踪: The HTTP service located at https://my.web.service.com/Service/Service.svc is unavailable. This could be because the service is too busy or because no endpoint was found listening at

我对繁忙的wcf服务有一个问题,客户可以通过该服务连接并使用它。 下面是该类的服务器配置和属性的错误和堆栈跟踪

错误消息和堆栈跟踪:

The HTTP service located at https://my.web.service.com/Service/Service.svc is unavailable.  This could be because the service is too busy or because no endpoint was found listening at the specified address. Please ensure that the address is correct and try accessing the service again later.ExST: 
Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
   at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Web服务器配置:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="Server.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
      <section name="ServerEdi.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </sectionGroup>
  </configSections>

  <system.web>
    <httpRuntime maxRequestLength="65536"/>
    <customErrors mode="Off"/>
    <compilation targetFramework="4.5"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>

  <system.serviceModel>

    <bindings>
      <wsHttpBinding>
        <binding name="IWebService" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" negotiateServiceCredential="true"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="nowa" name="ServiceWeb.WebService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="IWebService"
          contract="ServiceWeb.IWebService" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="nowa">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceCredentials>
            <serviceCertificate findValue="xxxyyyzzz.com" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ServiceWeb.MyCustomUserNamePasswordValidator,ServiceWeb"/>
            <windowsAuthentication includeWindowsGroups="false" allowAnonymousLogons="false"/>
          </serviceCredentials>
          <serviceAuthorization impersonateCallerForAllOperations="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="500" maxConcurrentSessions="500" />

        </behavior>

      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>

  <system.webServer>
    <urlCompression doStaticCompression="false"/>
  </system.webServer>

</configuration>   

如果有人能帮助我,我将非常感谢stackoverflow上描述的案例不完全适合并解决我的案例。目前,这项服务正在使用大约50名客户。当我调用一个返回某些内容的方法时,问题就出现了,而您不能异步调用它,因为答案必须立即传递。

WCF有一些默认限制值,因此您可能遇到了这些限制值,请参阅:


通常,当客户端未关闭连接时,会出现此错误,连接会一直打开直到超时,从而阻止任何新的调用。

当您说“当我调用一个返回某个内容的方法时出现问题,而您不能异步调用它,因为必须立即传递答案。”它会花多长时间,使它同步不会使它返回更快?我知道,客户端将等待答案,这是对象的信息,为他下一步做什么。我可以建议你也考虑线程池设置。(请参阅答案)Phil_P-线程池设置似乎很好,但如果您有任何怀疑,我可以提供线程池配置。如果他们在调用代码时未在代码周围使用“using”语句,是否会导致这种情况?我不这么认为,在我的代码中,我尝试了在try中使用try catch with close()的选项,并在catch中使用abort()call。这并不能解决问题。Shiraz Bhaiji-这样我就可以删除我的节流设置,因为默认设置没有问题。@Shiraz:所以如果我的客户端代码没有关闭WCF服务连接,就会发生这种情况?
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
   //[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
  //  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall,
   //              ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class WebService : IWebService {}