【问题标题】:wcf max message sizewcf 最大消息大小
【发布时间】:2010-09-27 00:23:01
【问题描述】:

我有两个服务,并且在它们之间发送相当大的消息(~100kb)。虽然前面提到的值是消息大小的典型值,但它可能会大幅波动(正向和负向)。

因此,为了处理我必须传输膨胀消息的情况,我已经在客户端和服务器端的 app.config 中设置了所有最大消息大小、最大字符串大小等属性(正确使用相关端点引用说明尺寸的绑定)。

为了安全起见,我设置的界限完全超过了任何可能的消息大小。然而,在消息大小规模的低端证明服务间通信可靠的情况下,在较高端情况并非如此 - 消息似乎根本没有传递。

最奇怪的是,如果消息超过了最大大小,那么就会抛出一个异常(我已经遇到了足够多的这些,知道这一点!哈哈),但什么都没有抛出——一切都过去了通过完全沉默。我已经尝试过各种大小的消息,并且它肯定只是随着消息大小的增长才开始发生。我可以证明目标服务没有接收到,因为在接收到后,该服务会在数据库中记录日志 - 但是对于大消息,不会生成日志。

正如我所说,我几乎可以肯定我已经增加了 app.config 中所有适用属性的大小,因此我完全被这种行为所困扰!

关于什么可能导致这种神秘行为的任何建议?

【问题讨论】:

  • 您是否检查过 IIS 日志以查看是否收到了大消息?

标签: wcf size service message max


【解决方案1】:

好吧,这个问题似乎已经解决了(突然间,在之前从未抱怨过之后,WCF 开始对 app.config 中的某个值感到不安,然后改变了它,然后它似乎工作了!)

但是现在我有一个同样奇怪的问题!出于某种原因,它拒绝接受我已配置要发布的元数据。我的 app.config(主机端)设置如下:

<services>
  <service name="DataFeederService.FeederService" behaviorConfiguration="DataFeederService.FeederServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8010/Feeder"/>
        <add baseAddress="net.pipe://localhost/FeederPipe"/>
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint name="namedPipeEndpoint" 
    address=""  
    bindingConfiguration="IPCWindowsSecurity" 
    binding="netNamedPipeBinding" 
    contract="DataFeederService.IFeederService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

    <endpoint name="httpEndpoint" 
    address="FeederService" 
    binding="wsHttpBinding" 
    bindingConfiguration="httpBinding" 
    contract="DataFeederService.IWebFeederService"/>

    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

<bindings>
  <netNamedPipeBinding>
    <binding name="IPCWindowsSecurity" 
    maxBufferPoolSize="965536" 
    maxBufferSize="965536" 
    maxReceivedMessageSize="965536">
      <readerQuotas maxStringContentLength="965536" />
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netNamedPipeBinding>
  <wsHttpBinding>
    <binding name="httpBinding" 
    maxBufferPoolSize="965536"
    maxReceivedMessageSize="965536">
      <readerQuotas maxStringContentLength="965536" />
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="DataFeederService.FeederServiceBehavior">
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="True" policyVersion="Policy15"/>
      <!-- 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" httpHelpPageEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我已尽力弄清楚为什么它会声称元数据未在指定地址“http://localhost:8010/Feeder/mex”上发布。任何帮助将不胜感激。

干杯!

【讨论】:

    【解决方案2】:

    对不起,经过进一步的拖网,我发现了错误的根源! datacontract 中的一个类已被更改([DataContract] 属性已被删除,但奇怪的是 [DataMemeber] 已留在相关属性上!非常奇怪!)

    无论如何,感谢您的所有帮助,尤其是您让我走到了这一步,我终于可以摆脱这个该死的项目了 :-)

    【讨论】:

      【解决方案3】:

      WCF 偶尔会出现问题,这会导致它“静默”失败(即没有例外),这可能很难调试。听起来这可能就是您所看到的情况。

      在这种情况下,WCF 中的enabling the tracing options 非常有帮助,因为它可以让您查看消息是否确实到达了服务以及调度程序如何处理它。

      【讨论】:

        猜你喜欢
        • 2010-12-15
        • 2017-05-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-02
        • 2013-11-03
        • 1970-01-01
        • 2010-10-28
        相关资源
        最近更新 更多