1

我有一个托管在 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>

4

2 回答 2

1

您似乎没有增加服务器端各种参数的大小 - 您绝对应该尝试一下!也可以在服务器端使用客户端配置文件中的绑定配置 - 服务可能会阻塞,因为它仍然默认为 64K 消息大小。

此外,receiveTimeout在您的客户端绑定中有点有趣 - 它缺少一个零位:

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

你应该使用receiveTimeout="00:01:00"

马克

于 2009-07-30T16:41:25.137 回答
0

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

DataSet 被 WCF 以 XML 格式序列化。我强制 DataSet 序列化为 byte[] 并且时间减少到 4 秒。一种猜测是转义 4MB XML 中的所有字符以使 HTTP 通信有效是导致问题的原因。

于 2009-07-31T19:11:26.033 回答