【问题标题】:WCF default binding configuration settings not taking effect on hostWCF 默认绑定配置设置未在主机上生效
【发布时间】:2014-11-21 17:33:46
【问题描述】:

我的 WCF 服务抛出 ProtocolException (403) - 请求实体太大。将文件 (~100KiB) 推送到服务时会发生这种情况。

奇怪的是,这只发生在托管(暂存)版本上,而不是本地。我的客户端配置是:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="DefaultBindingConfiguration" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="1000000000">
                <readerQuotas maxDepth="1000000000" maxStringContentLength="1000000000" maxArrayLength="64000000" maxBytesPerRead="1000000000" maxNameTableCharCount="1000000000" />
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    ...
</system.serviceModel>

我的服务器配置是:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" maxBufferPoolSize="1000000000" sendTimeout="01:00:00" receiveTimeout="01:00:00">
                <readerQuotas maxDepth="1000000000" maxStringContentLength="1000000000" maxArrayLength="1000000000" maxBytesPerRead="1000000000" />
                <security mode="None"/>
            </binding>
        </basicHttpBinding>
    </bindings>
    ...
</system.serviceModel>

为简洁起见,我省略了&lt;behaviours&gt; 部分。客户端以编程方式创建端点,全部使用DefaultBindingConfiguration。我可以通过选择性地将值减小到1 来确认服务器和客户端绑定配置正在本地生效,然后看到它失败了。

任何想法为什么托管服务器的行为可能与我的本地服务器不同?显着差异:

  • 本地操作系统:Windows 7,主机操作系统:Windows Server 2012
  • 本地 IIS:7,主机 IIS 8(.5?)

注意:为了先发制人“那些值太高”和“不要设置全局值”,我知道风险所以不要'不需要提醒。 :)

非常感谢任何指针和建议。

更新:
此问题已自行解决。重新启动网络场中的节点后,不再显示此行为。这并没有让我充满信心,因为如果它再次发生,我不知道如何解决它。我欢迎提供可以说明为什么会出现这种情况的答案...

【问题讨论】:

标签: .net wcf wcf-binding throttling basichttpbinding


【解决方案1】:

我会检查 IIS 管理器以查看设置是否不同,但也许您可以在 web.config 上设置明确的请求长度值,更多信息here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    相关资源
    最近更新 更多