我在IIS7中托管了一个WCF服务(服务和客户端配置在本文末尾)。我碰到了一个奇怪的场景,我希望有人可能对如何攻击它并找到解决方案有一些想法。

该服务仅公开一个合同“ProcessMessage”。我可以使用该合同从服务发送/接收同步消息,但预期性能很好,但是对该合同的一次特定调用会返回超过65KB的数据;大约1 MB。在最初调用它时,我收到了预期的最大接收大小超出错误。所以我增加了maxReceivedMessageSize,现在这个特定的调用需要40分钟才能返回到客户端。这远远超出了任何超时设置,远远超出了我的预期。服务器端处理时间仅为2秒。它似乎在客户端被搁置。

我也试过碰到文件中的其他几个配额无济于事。

任何想法都将不胜感激。感谢。

服务配置:

  <system.serviceModel>
<services>
  <service behaviorConfiguration="Lrs.Esf.Facade.Startup.FacadeBehavior"
    name="Lrs.Esf.Facade.Startup.FacadeService">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="default" contract="Lrs.Esf.Facade.Startup.IFacadeService">
      <identity>
        <servicePrincipalName value="lrsdomain/PensionDev" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="default">
      <security mode="None"/>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="Lrs.Esf.Facade.Startup.FacadeBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="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" />

    </behavior>
  </serviceBehaviors>
</behaviors>

客户端配置:

  <system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IFacadeService" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:1:00" sendTimeout="00:01:00"
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">          
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://esf2.facade.testpe.pg.local/FacadeWcf/FacadeService.svc"
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFacadeService"
      contract="FacadeServiceReference.IFacadeService" name="WSHttpBinding_IFacadeService">
    <identity>
      <servicePrincipalName value="lrsdomain/PensionDev" />
    </identity>
  </endpoint>
</client>

有帮助吗?

解决方案 2

我已经找到问题的根本原因和解决方法,但是额外的洞察力会很棒。

WCF正在以XML格式对DataSet进行序列化。我强制DataSet序列化为byte [],时间减少到4秒。一个猜测是,在4MB的XML中转义所有字符以便HTTP通信有效是导致问题的原因。

其他提示

你没有增加服务器端各种参数的大小,看起来 - 你一定要试试!使用服务器端客户端配置文件中的绑定配置 - 服务可能会因为它仍然默认为64K消息大小而窒息。

此外,客户端绑定中的 receiveTimeout 有点搞笑 - 它缺少一个零数字:

<binding name="WSHttpBinding_IFacadeService" 
receiveTimeout="00:1:00" 

你应该使用 receiveTimeout =&quot; 00:01:00&quot;

马克

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top