【问题标题】:Unable to upload large file via nettcp binding and transfermode="buffered"无法通过 nettcp 绑定和 transfermode="buffered" 上传大文件
【发布时间】:2014-10-28 17:36:25
【问题描述】:

我有一个应用程序,我在其中一种方法中将文件传输到服务器。

我可以轻松上传大约 50 KB 的文件。但我的最大限制约为 3 MB。

我的 WCR 服务通过 nettcpbinding 托管在 Windows 服务中

我的windows配置是

<configuration>  
  <system.serviceModel>
    <services>
      <service name="BTWAServerWindowsService.BatchManagementService"
               behaviorConfiguration ="BatchManagementService">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9999/BatchManagementService" />
          </baseAddresses>
        </host>
        <endpoint name="BatchManagementServiceEndPoint"
        address =""
        binding="netTcpBinding"
        contract="BTWAServerWindowsService.IBatchManagementService">
        </endpoint>
        <endpoint name="BatchManagementServiceMetadataPoint" address="mex"
                binding="mexTcpBinding"
                contract="IMetadataExchange"/>
      </service>      
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BatchManagementService">
          <serviceMetadata httpGetEnabled="False"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>       
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

我的客户端配置是

<configuration> 
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="BatchManagementServiceEndPoint" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="524288"
          maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="524288"
          maxReceivedMessageSize="524288">
          <readerQuotas maxDepth="524288" maxStringContentLength="524288"
            maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>       
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:9999/BatchManagementService"
        binding="netTcpBinding" bindingConfiguration="BatchManagementServiceEndPoint"
        contract="BTWABatchManagement.IBatchManagementService" name="BatchManagementServiceEndPoint" />      
    </client>
  </system.serviceModel>
</configuration>

目前我无法将传输模式更改为流式传输,因为还有许多其他方法

请建议我将文件限制增加到 4 mb 所需的配置更改

【问题讨论】:

    标签: c# .net wcf .net-3.5 nettcpbinding


    【解决方案1】:

    在服务端 app.config 和客户端 app.config 中的 netTcpBinding 中更改以下属性

    maxBufferPoolSize="1073741824" maxBufferSize="1073741824" maxConnections="10"
              maxReceivedMessageSize="1073741824">
              <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    

    这些属性的最大值是2147483647

    <bindings>
          <netTcpBinding>
            <binding name="BatchManagementServiceEndPoint" closeTimeout="00:10:00"
              openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
              transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
              hostNameComparisonMode="StrongWildcard" listenBacklog="524288"
              maxBufferPoolSize="1073741824" maxBufferSize="1073741824" maxConnections="10"
              maxReceivedMessageSize="1073741824">
              <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>       
          </netTcpBinding>
    </bindings>
    

    希望对你有帮助

    【讨论】:

    猜你喜欢
    • 2018-08-06
    • 2010-12-08
    • 1970-01-01
    • 2023-04-11
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2022-08-23
    相关资源
    最近更新 更多